<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The AQUA Project, Glasgow University, 1998

-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span class="hs-comment">-- | Typechecking @foreign@ declarations</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- A foreign declaration is used to either give an externally</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- implemented function a Haskell type (and calling interface) or</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- give a Haskell function an external calling interface. Either way,</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- the range of argument and result types these functions can accommodate</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- is restricted to what the outside world understands (read C), and this</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- module checks to see if a foreign declaration has got a legal type.</span><span>
</span><span id="line-18"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Gen.Foreign</span><span>
</span><span id="line-19"></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcForeignImports"><span class="hs-identifier">tcForeignImports</span></a></span><span>
</span><span id="line-20"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcForeignExports"><span class="hs-identifier">tcForeignExports</span></a></span><span>
</span><span id="line-21"></span><span>
</span><span id="line-22"></span><span>        </span><span class="hs-comment">-- Low-level exports for hooks</span><span>
</span><span id="line-23"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#isForeignImport"><span class="hs-identifier">isForeignImport</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#isForeignExport"><span class="hs-identifier">isForeignExport</span></a></span><span>
</span><span id="line-24"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcFImport"><span class="hs-identifier">tcFImport</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcFExport"><span class="hs-identifier">tcFExport</span></a></span><span>
</span><span id="line-25"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcForeignImports%27"><span class="hs-identifier">tcForeignImports'</span></a></span><span>
</span><span id="line-26"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcCheckFIType"><span class="hs-identifier">tcCheckFIType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCTarget"><span class="hs-identifier">checkCTarget</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkForeignArgs"><span class="hs-identifier">checkForeignArgs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier">checkForeignRes</span></a></span><span>
</span><span id="line-27"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#normaliseFfiType"><span class="hs-identifier">normaliseFfiType</span></a></span><span>
</span><span id="line-28"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#nonIOok"><span class="hs-identifier">nonIOok</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#mustBeIO"><span class="hs-identifier">mustBeIO</span></a></span><span>
</span><span id="line-29"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkSafe"><span class="hs-identifier">checkSafe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#noCheckSafe"><span class="hs-identifier">noCheckSafe</span></a></span><span>
</span><span id="line-30"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcForeignExports%27"><span class="hs-identifier">tcForeignExports'</span></a></span><span>
</span><span id="line-31"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcCheckFEType"><span class="hs-identifier">tcCheckFEType</span></a></span><span>
</span><span id="line-32"></span><span>        </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.HsType.html"><span class="hs-identifier">GHC.Tc.Gen.HsType</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Expr.html"><span class="hs-identifier">GHC.Tc.Gen.Expr</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span>
</span><span id="line-44"></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Family.html"><span class="hs-identifier">GHC.Tc.Instance.Family</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html"><span class="hs-identifier">GHC.Core.FamInstEnv</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.html"><span class="hs-identifier">GHC.Core.Coercion</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html"><span class="hs-identifier">GHC.Types.ForeignCall</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html"><span class="hs-identifier">GHC.Types.Name.Reader</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Outputable</span></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Hooks.html"><span class="hs-identifier">GHC.Driver.Hooks</span></a></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-comment">-- Defines a binding</span><span>
</span><span id="line-70"></span><span id="local-6989586621681175856"><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#isForeignImport"><span class="hs-identifier hs-type">isForeignImport</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681175856"><span class="hs-identifier hs-type">name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-71"></span><span id="isForeignImport"><span class="annot"><span class="annottext">isForeignImport :: forall name. LForeignDecl name -&gt; Bool
</span><a href="GHC.Tc.Gen.Foreign.html#isForeignImport"><span class="hs-identifier hs-var hs-var">isForeignImport</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignImport"><span class="hs-identifier hs-type">ForeignImport</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-72"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#isForeignImport"><span class="hs-identifier hs-var">isForeignImport</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (ForeignDecl name)
</span><span class="hs-identifier">_</span></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-comment">-- Exports a binding</span><span>
</span><span id="line-75"></span><span id="local-6989586621681175561"><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#isForeignExport"><span class="hs-identifier hs-type">isForeignExport</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681175561"><span class="hs-identifier hs-type">name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-76"></span><span id="isForeignExport"><span class="annot"><span class="annottext">isForeignExport :: forall name. LForeignDecl name -&gt; Bool
</span><a href="GHC.Tc.Gen.Foreign.html#isForeignExport"><span class="hs-identifier hs-var hs-var">isForeignExport</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignExport"><span class="hs-identifier hs-type">ForeignExport</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-77"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#isForeignExport"><span class="hs-identifier hs-var">isForeignExport</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (ForeignDecl name)
</span><span class="hs-identifier">_</span></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="hs-comment">{-
Note [Don't recur in normaliseFfiType']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
normaliseFfiType' is the workhorse for normalising a type used in a foreign
declaration. If we have

newtype Age = MkAge Int

we want to see that Age -&gt; IO () is the same as Int -&gt; IO (). But, we don't
need to recur on any type parameters, because no paramaterized types (with
interesting parameters) are marshalable! The full list of marshalable types
is in the body of boxedMarshalableTyCon in GHC.Tc.Utils.TcType. The only members of that
list not at kind * are Ptr, FunPtr, and StablePtr, all of which get marshaled
the same way regardless of type parameter. So, no need to recur into
parameters.

Similarly, we don't need to look in AppTy's, because nothing headed by
an AppTy will be marshalable.
-}</span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-comment">-- normaliseFfiType takes the type from an FFI declaration, and</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- evaluates any type synonyms, type functions, and newtypes. However,</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- we are only allowed to look through newtypes if the constructor is</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- in scope.  We return a bag of all the newtype constructors thus found.</span><span>
</span><span id="line-103"></span><span class="hs-comment">-- Always returns a Representational coercion</span><span>
</span><span id="line-104"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#normaliseFfiType"><span class="hs-identifier hs-type">normaliseFfiType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-105"></span><span id="normaliseFfiType"><span class="annot"><span class="annottext">normaliseFfiType :: Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#normaliseFfiType"><span class="hs-identifier hs-var hs-var">normaliseFfiType</span></a></span></span><span> </span><span id="local-6989586621681175559"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175559"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-106"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681175558"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681175558"><span class="hs-identifier hs-var">fam_envs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM FamInstEnvs
</span><a href="GHC.Tc.Instance.Family.html#tcGetFamInstEnvs"><span class="hs-identifier hs-var">tcGetFamInstEnvs</span></a></span><span>
</span><span id="line-107"></span><span>         </span><span class="annot"><span class="annottext">FamInstEnvs -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#normaliseFfiType%27"><span class="hs-identifier hs-var">normaliseFfiType'</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681175558"><span class="hs-identifier hs-var">fam_envs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175559"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#normaliseFfiType%27"><span class="hs-identifier hs-type">normaliseFfiType'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInstEnvs"><span class="hs-identifier hs-type">FamInstEnvs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-110"></span><span id="normaliseFfiType%27"><span class="annot"><span class="annottext">normaliseFfiType' :: FamInstEnvs -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#normaliseFfiType%27"><span class="hs-identifier hs-var hs-var">normaliseFfiType'</span></a></span></span><span> </span><span id="local-6989586621681175555"><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681175555"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681175554"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175554"><span class="hs-identifier hs-var">ty0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
-&gt; RecTcChecker -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175553"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="GHC.Core.TyCon.html#initRecTc"><span class="hs-identifier hs-var">initRecTc</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175554"><span class="hs-identifier hs-var">ty0</span></a></span><span>
</span><span id="line-111"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-112"></span><span>    </span><span class="annot"><a href="#local-6989586621681175553"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#RecTcChecker"><span class="hs-identifier hs-type">RecTcChecker</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-113"></span><span>    </span><span id="local-6989586621681175553"><span class="annot"><span class="annottext">go :: Role
-&gt; RecTcChecker -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175553"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681175550"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175550"><span class="hs-keyword hs-var">role</span></a></span></span><span> </span><span id="local-6989586621681175549"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175549"><span class="hs-identifier hs-var">rec_nts</span></a></span></span><span> </span><span id="local-6989586621681175548"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175548"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-114"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681175547"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175547"><span class="hs-identifier hs-var">ty'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe Type
</span><a href="GHC.Core.Type.html#tcView"><span class="hs-identifier hs-var">tcView</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175548"><span class="hs-identifier hs-var">ty</span></a></span><span>     </span><span class="hs-comment">-- Expand synonyms</span><span>
</span><span id="line-115"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
-&gt; RecTcChecker -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175553"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175550"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175549"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175547"><span class="hs-identifier hs-var">ty'</span></a></span><span>
</span><span id="line-116"></span><span>
</span><span id="line-117"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175545"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175545"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175544"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175544"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, [Type])
Type -&gt; Maybe (TyCon, [Type])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175548"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-118"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
-&gt; RecTcChecker
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175542"><span class="hs-identifier hs-var">go_tc_app</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175550"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175549"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175545"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175544"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175541"><span class="annot"><span class="annottext">[TyCoVarBinder]
</span><a href="#local-6989586621681175541"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175540"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175540"><span class="hs-identifier hs-var">inner_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([TyCoVarBinder], Type)
</span><a href="GHC.Core.Type.html#splitForAllVarBndrs"><span class="hs-identifier hs-var">splitForAllVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175548"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-121"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVarBinder] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVarBinder]
</span><a href="#local-6989586621681175541"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175536"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175536"><span class="hs-identifier hs-var">coi</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175535"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175535"><span class="hs-identifier hs-var">nty1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175534"><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175534"><span class="hs-identifier hs-var">gres1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Role
-&gt; RecTcChecker -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175553"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175550"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175549"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175540"><span class="hs-identifier hs-var">inner_ty</span></a></span><span>
</span><span id="line-123"></span><span>           </span><span class="annot"><span class="annottext">(Coercion, Type, Bag GlobalRdrElt)
-&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[TyCoVar] -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkHomoForAllCos"><span class="hs-identifier hs-var">mkHomoForAllCos</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVarBinder] -&gt; [TyCoVar]
forall tv argf. [VarBndr tv argf] -&gt; [tv]
</span><a href="GHC.Types.Var.html#binderVars"><span class="hs-identifier hs-var">binderVars</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVarBinder]
</span><a href="#local-6989586621681175541"><span class="hs-identifier hs-var">bndrs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175536"><span class="hs-identifier hs-var">coi</span></a></span><span>
</span><span id="line-124"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[TyCoVarBinder] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkForAllTys"><span class="hs-identifier hs-var">mkForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCoVarBinder]
</span><a href="#local-6989586621681175541"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175535"><span class="hs-identifier hs-var">nty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175534"><span class="hs-identifier hs-var">gres1</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-125"></span><span>
</span><span id="line-126"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-comment">-- see Note [Don't recur in normaliseFfiType']</span><span>
</span><span id="line-127"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion, Type, Bag GlobalRdrElt)
-&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175550"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175548"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175548"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-128"></span><span>
</span><span id="line-129"></span><span>    </span><span class="annot"><a href="#local-6989586621681175542"><span class="hs-identifier hs-type">go_tc_app</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html#Role"><span class="hs-identifier hs-type">Role</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#RecTcChecker"><span class="hs-identifier hs-type">RecTcChecker</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-130"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-131"></span><span>    </span><span id="local-6989586621681175542"><span class="annot"><span class="annottext">go_tc_app :: Role
-&gt; RecTcChecker
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175542"><span class="hs-identifier hs-var hs-var">go_tc_app</span></a></span></span><span> </span><span id="local-6989586621681175528"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175528"><span class="hs-keyword hs-var">role</span></a></span></span><span> </span><span id="local-6989586621681175527"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175527"><span class="hs-identifier hs-var">rec_nts</span></a></span></span><span> </span><span id="local-6989586621681175526"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681175525"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175525"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-132"></span><span>        </span><span class="hs-comment">-- We don't want to look through the IO newtype, even if it is</span><span>
</span><span id="line-133"></span><span>        </span><span class="hs-comment">-- in scope, so we have a special case for it:</span><span>
</span><span id="line-134"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681175524"><span class="hs-identifier hs-var">tc_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; [Unique] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#ioTyConKey"><span class="hs-identifier hs-var">ioTyConKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#funPtrTyConKey"><span class="hs-identifier hs-var">funPtrTyConKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#funTyConKey"><span class="hs-identifier hs-var">funTyConKey</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-135"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175519"><span class="hs-identifier hs-var">children_only</span></a></span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isNewTyCon"><span class="hs-identifier hs-var">isNewTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span>         </span><span class="hs-comment">-- Expand newtypes</span><span>
</span><span id="line-138"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681175517"><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175517"><span class="hs-identifier hs-var">rec_nts'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">RecTcChecker -&gt; TyCon -&gt; Maybe RecTcChecker
</span><a href="GHC.Core.TyCon.html#checkRecTc"><span class="hs-identifier hs-var">checkRecTc</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175527"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-139"></span><span>                   </span><span class="hs-comment">-- See Note [Expanding newtypes] in GHC.Core.TyCon</span><span>
</span><span id="line-140"></span><span>                   </span><span class="hs-comment">-- We can't just use isRecursiveTyCon; sometimes recursion is ok:</span><span>
</span><span id="line-141"></span><span>                   </span><span class="hs-comment">--     newtype T = T (Ptr T)</span><span>
</span><span id="line-142"></span><span>                   </span><span class="hs-comment">--   Here, we don't reject the type for being recursive.</span><span>
</span><span id="line-143"></span><span>                   </span><span class="hs-comment">-- If this is a recursive newtype then it will normally</span><span>
</span><span id="line-144"></span><span>                   </span><span class="hs-comment">-- be rejected later as not being a valid FFI type.</span><span>
</span><span id="line-145"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681175515"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681175515"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn GlobalRdrEnv
</span><a href="GHC.Tc.Utils.Monad.html#getGlobalRdrEnv"><span class="hs-identifier hs-var">getGlobalRdrEnv</span></a></span><span>
</span><span id="line-146"></span><span>             </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; TyCon -&gt; Maybe GlobalRdrElt
</span><a href="GHC.Tc.Gen.Foreign.html#checkNewtypeFFI"><span class="hs-identifier hs-var">checkNewtypeFFI</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681175515"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-147"></span><span>                 </span><span class="annot"><span class="annottext">Maybe GlobalRdrElt
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175512"><span class="hs-identifier hs-var">nothing</span></a></span><span>
</span><span id="line-148"></span><span>                 </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681175511"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681175511"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175510"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175510"><span class="hs-identifier hs-var">co'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175509"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175509"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175508"><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175508"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Role
-&gt; RecTcChecker -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175553"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175528"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175517"><span class="hs-identifier hs-var">rec_nts'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175507"><span class="hs-identifier hs-var">nt_rhs</span></a></span><span>
</span><span id="line-149"></span><span>                                </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Coercion, Type, Bag GlobalRdrElt)
-&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-identifier hs-var">mkTransCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175505"><span class="hs-identifier hs-var">nt_co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175510"><span class="hs-identifier hs-var">co'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175509"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681175511"><span class="hs-identifier hs-var">gre</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Bag GlobalRdrElt -&gt; Bag GlobalRdrElt
forall a. a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#consBag"><span class="hs-operator hs-var">`consBag`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175508"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-150"></span><span>
</span><span id="line-151"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isFamilyTyCon"><span class="hs-identifier hs-var">isFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span>              </span><span class="hs-comment">-- Expand open tycons</span><span>
</span><span id="line-152"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175502"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175502"><span class="hs-identifier hs-var">co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175501"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175501"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FamInstEnvs -&gt; Role -&gt; TyCon -&gt; [Type] -&gt; (Coercion, Type)
</span><a href="GHC.Core.FamInstEnv.html#normaliseTcApp"><span class="hs-identifier hs-var">normaliseTcApp</span></a></span><span> </span><span class="annot"><span class="annottext">FamInstEnvs
</span><a href="#local-6989586621681175555"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175528"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175525"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-153"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Bool
</span><a href="GHC.Core.Coercion.html#isReflexiveCo"><span class="hs-identifier hs-var">isReflexiveCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175502"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-154"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175498"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175498"><span class="hs-identifier hs-var">co'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175497"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175497"><span class="hs-identifier hs-var">ty'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175496"><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175496"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Role
-&gt; RecTcChecker -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175553"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175528"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175527"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175501"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-155"></span><span>             </span><span class="annot"><span class="annottext">(Coercion, Type, Bag GlobalRdrElt)
-&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTransCo"><span class="hs-identifier hs-var">mkTransCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175502"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175498"><span class="hs-identifier hs-var">co'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175497"><span class="hs-identifier hs-var">ty'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175496"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-158"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175512"><span class="hs-identifier hs-var">nothing</span></a></span><span> </span><span class="hs-comment">-- see Note [Don't recur in normaliseFfiType']</span><span>
</span><span id="line-159"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-160"></span><span>          </span><span id="local-6989586621681175524"><span class="annot"><span class="annottext">tc_key :: Unique
</span><a href="#local-6989586621681175524"><span class="hs-identifier hs-var hs-var">tc_key</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique
forall a. Uniquable a =&gt; a -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-161"></span><span>          </span><span id="local-6989586621681175519"><span class="annot"><span class="annottext">children_only :: TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175519"><span class="hs-identifier hs-var hs-var">children_only</span></a></span></span><span>
</span><span id="line-162"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681175494"><span class="annot"><span class="annottext">[(Coercion, Type, Bag GlobalRdrElt)]
</span><a href="#local-6989586621681175494"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Role -&gt; TcM (Coercion, Type, Bag GlobalRdrElt))
-&gt; [Type]
-&gt; [Role]
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) [(Coercion, Type, Bag GlobalRdrElt)]
forall (m :: * -&gt; *) a b c.
Applicative m =&gt;
(a -&gt; b -&gt; m c) -&gt; [a] -&gt; [b] -&gt; m [c]
</span><a href="../../base/src/Control.Monad.html#zipWithM"><span class="hs-identifier hs-var">zipWithM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681175492"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175492"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681175491"><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175491"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Role
-&gt; RecTcChecker -&gt; Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175553"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175491"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">RecTcChecker
</span><a href="#local-6989586621681175527"><span class="hs-identifier hs-var">rec_nts</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175492"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175525"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TyCon -&gt; [Role]
</span><a href="GHC.Core.Coercion.html#tyConRolesX"><span class="hs-identifier hs-var">tyConRolesX</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175528"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-163"></span><span>                 </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175489"><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681175489"><span class="hs-identifier hs-var">cos</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175488"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175488"><span class="hs-identifier hs-var">tys'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175487"><span class="annot"><span class="annottext">[Bag GlobalRdrElt]
</span><a href="#local-6989586621681175487"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Coercion, Type, Bag GlobalRdrElt)]
-&gt; ([Coercion], [Type], [Bag GlobalRdrElt])
forall a b c. [(a, b, c)] -&gt; ([a], [b], [c])
</span><a href="../../base/src/GHC.List.html#unzip3"><span class="hs-identifier hs-var">unzip3</span></a></span><span> </span><span class="annot"><span class="annottext">[(Coercion, Type, Bag GlobalRdrElt)]
</span><a href="#local-6989586621681175494"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-164"></span><span>                 </span><span class="annot"><span class="annottext">(Coercion, Type, Bag GlobalRdrElt)
-&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Role -&gt; TyCon -&gt; [Coercion] -&gt; Coercion
Role -&gt; TyCon -&gt; [Coercion] -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkTyConAppCo"><span class="hs-identifier hs-var">mkTyConAppCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175528"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Coercion]
</span><a href="#local-6989586621681175489"><span class="hs-identifier hs-var">cos</span></a></span><span>
</span><span id="line-165"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175488"><span class="hs-identifier hs-var">tys'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Bag GlobalRdrElt] -&gt; Bag GlobalRdrElt
forall a. [Bag a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionManyBags"><span class="hs-identifier hs-var">unionManyBags</span></a></span><span> </span><span class="annot"><span class="annottext">[Bag GlobalRdrElt]
</span><a href="#local-6989586621681175487"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-166"></span><span>          </span><span id="local-6989586621681175505"><span class="annot"><span class="annottext">nt_co :: Coercion
</span><a href="#local-6989586621681175505"><span class="hs-identifier hs-var hs-var">nt_co</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role -&gt; CoAxiom Unbranched -&gt; [Type] -&gt; [Coercion] -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkUnbranchedAxInstCo"><span class="hs-identifier hs-var">mkUnbranchedAxInstCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175528"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; CoAxiom Unbranched
</span><a href="GHC.Core.TyCon.html#newTyConCo"><span class="hs-identifier hs-var">newTyConCo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175525"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-167"></span><span>          </span><span id="local-6989586621681175507"><span class="annot"><span class="annottext">nt_rhs :: Type
</span><a href="#local-6989586621681175507"><span class="hs-identifier hs-var hs-var">nt_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Type
</span><a href="GHC.Core.Type.html#newTyConInstRhs"><span class="hs-identifier hs-var">newTyConInstRhs</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175525"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-168"></span><span>
</span><span id="line-169"></span><span>          </span><span id="local-6989586621681175479"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621681175479"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175526"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175525"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-170"></span><span>          </span><span id="local-6989586621681175512"><span class="annot"><span class="annottext">nothing :: TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="#local-6989586621681175512"><span class="hs-identifier hs-var hs-var">nothing</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion, Type, Bag GlobalRdrElt)
-&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; Type -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkReflCo"><span class="hs-identifier hs-var">mkReflCo</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="#local-6989586621681175528"><span class="hs-keyword hs-var">role</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175479"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175479"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkNewtypeFFI"><span class="hs-identifier hs-type">checkNewtypeFFI</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrEnv"><span class="hs-identifier hs-type">GlobalRdrEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span>
</span><span id="line-173"></span><span id="checkNewtypeFFI"><span class="annot"><span class="annottext">checkNewtypeFFI :: GlobalRdrEnv -&gt; TyCon -&gt; Maybe GlobalRdrElt
</span><a href="GHC.Tc.Gen.Foreign.html#checkNewtypeFFI"><span class="hs-identifier hs-var hs-var">checkNewtypeFFI</span></a></span></span><span> </span><span id="local-6989586621681175478"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681175478"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span> </span><span id="local-6989586621681175477"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175477"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-174"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681175476"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681175476"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Maybe DataCon
</span><a href="GHC.Core.TyCon.html#tyConSingleDataCon_maybe"><span class="hs-identifier hs-var">tyConSingleDataCon_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681175477"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-175"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681175474"><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681175474"><span class="hs-identifier hs-var">gre</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv -&gt; Name -&gt; Maybe GlobalRdrElt
</span><a href="GHC.Types.Name.Reader.html#lookupGRE_Name"><span class="hs-identifier hs-var">lookupGRE_Name</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681175478"><span class="hs-identifier hs-var">rdr_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Name
</span><a href="GHC.Core.DataCon.html#dataConName"><span class="hs-identifier hs-var">dataConName</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681175476"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-176"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt -&gt; Maybe GlobalRdrElt
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrElt
</span><a href="#local-6989586621681175474"><span class="hs-identifier hs-var">gre</span></a></span><span>    </span><span class="hs-comment">-- See Note [Newtype constructor usage in foreign declarations]</span><span>
</span><span id="line-177"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-178"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe GlobalRdrElt
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-179"></span><span>
</span><span id="line-180"></span><span class="hs-comment">{-
Note [Newtype constructor usage in foreign declarations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GHC automatically &quot;unwraps&quot; newtype constructors in foreign import/export
declarations.  In effect that means that a newtype data constructor is
used even though it is not mentioned expclitly in the source, so we don't
want to report it as &quot;defined but not used&quot; or &quot;imported but not used&quot;.
eg     newtype D = MkD Int
       foreign import foo :: D -&gt; IO ()
Here 'MkD' us used.  See #7408.

GHC also expands type functions during this process, so it's not enough
just to look at the free variables of the declaration.
eg     type instance F Bool = D
       foreign import bar :: F Bool -&gt; IO ()
Here again 'MkD' is used.

So we really have wait until the type checker to decide what is used.
That's why tcForeignImports and tecForeignExports return a (Bag GRE)
for the newtype constructors they see. Then GHC.Tc.Module can add them
to the module's usages.


************************************************************************
*                                                                      *
\subsection{Imports}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcForeignImports"><span class="hs-identifier hs-type">tcForeignImports</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-211"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-212"></span><span id="tcForeignImports"><span class="annot"><span class="annottext">tcForeignImports :: [LForeignDecl GhcRn]
-&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcForeignImports"><span class="hs-identifier hs-var hs-var">tcForeignImports</span></a></span></span><span> </span><span id="local-6989586621681175470"><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
</span><a href="#local-6989586621681175470"><span class="hs-identifier hs-var">decls</span></a></span></span><span>
</span><span id="line-213"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Hooks
 -&gt; Maybe
      ([LForeignDecl GhcRn]
       -&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt)))
-&gt; ([LForeignDecl GhcRn]
    -&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     ([LForeignDecl GhcRn]
      -&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt))
forall (f :: * -&gt; *) a.
(Functor f, HasDynFlags f) =&gt;
(Hooks -&gt; Maybe a) -&gt; a -&gt; f a
</span><a href="GHC.Driver.Hooks.html#getHooked"><span class="hs-identifier hs-var">getHooked</span></a></span><span> </span><span class="annot"><span class="annottext">Hooks
-&gt; Maybe
     ([LForeignDecl GhcRn]
      -&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt))
</span><a href="GHC.Driver.Hooks.html#tcForeignImportsHook"><span class="hs-identifier hs-var hs-var">tcForeignImportsHook</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
-&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcForeignImports%27"><span class="hs-identifier hs-var">tcForeignImports'</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv
  (Env TcGblEnv TcLclEnv)
  ([LForeignDecl GhcRn]
   -&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; (([LForeignDecl GhcRn]
     -&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt))
    -&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([LForeignDecl GhcRn]
 -&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; [LForeignDecl GhcRn]
-&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
</span><a href="#local-6989586621681175470"><span class="hs-identifier hs-var">decls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-214"></span><span>
</span><span id="line-215"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcForeignImports%27"><span class="hs-identifier hs-type">tcForeignImports'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-216"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span class="hs-comment">-- For the (Bag GlobalRdrElt) result,</span><span>
</span><span id="line-218"></span><span class="hs-comment">-- see Note [Newtype constructor usage in foreign declarations]</span><span>
</span><span id="line-219"></span><span id="tcForeignImports%27"><span class="annot"><span class="annottext">tcForeignImports' :: [LForeignDecl GhcRn]
-&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcForeignImports%27"><span class="hs-identifier hs-var hs-var">tcForeignImports'</span></a></span></span><span> </span><span id="local-6989586621681175467"><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
</span><a href="#local-6989586621681175467"><span class="hs-identifier hs-var">decls</span></a></span></span><span>
</span><span id="line-220"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175466"><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621681175466"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175465"><span class="annot"><span class="annottext">[LForeignDecl GhcTc]
</span><a href="#local-6989586621681175465"><span class="hs-identifier hs-var">decls</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175464"><span class="annot"><span class="annottext">[Bag GlobalRdrElt]
</span><a href="#local-6989586621681175464"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LForeignDecl GhcRn
 -&gt; IOEnv
      (Env TcGblEnv TcLclEnv)
      (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt))
-&gt; [LForeignDecl GhcRn]
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     ([TyCoVar], [LForeignDecl GhcTc], [Bag GlobalRdrElt])
forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; m (b, c, d)) -&gt; [a] -&gt; m ([b], [c], [d])
</span><a href="GHC.Utils.Monad.html#mapAndUnzip3M"><span class="hs-identifier hs-var">mapAndUnzip3M</span></a></span><span> </span><span class="annot"><span class="annottext">LForeignDecl GhcRn
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcFImport"><span class="hs-identifier hs-var">tcFImport</span></a></span><span> </span><span class="annot"><span class="annottext">([LForeignDecl GhcRn]
 -&gt; IOEnv
      (Env TcGblEnv TcLclEnv)
      ([TyCoVar], [LForeignDecl GhcTc], [Bag GlobalRdrElt]))
-&gt; [LForeignDecl GhcRn]
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     ([TyCoVar], [LForeignDecl GhcTc], [Bag GlobalRdrElt])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-221"></span><span>                               </span><span class="annot"><span class="annottext">(LForeignDecl GhcRn -&gt; Bool)
-&gt; [LForeignDecl GhcRn] -&gt; [LForeignDecl GhcRn]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">LForeignDecl GhcRn -&gt; Bool
forall name. LForeignDecl name -&gt; Bool
</span><a href="GHC.Tc.Gen.Foreign.html#isForeignImport"><span class="hs-identifier hs-var">isForeignImport</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
</span><a href="#local-6989586621681175467"><span class="hs-identifier hs-var">decls</span></a></span><span>
</span><span id="line-222"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt)
-&gt; TcM ([TyCoVar], [LForeignDecl GhcTc], Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyCoVar]
</span><a href="#local-6989586621681175466"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcTc]
</span><a href="#local-6989586621681175465"><span class="hs-identifier hs-var">decls</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Bag GlobalRdrElt] -&gt; Bag GlobalRdrElt
forall a. [Bag a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionManyBags"><span class="hs-identifier hs-var">unionManyBags</span></a></span><span> </span><span class="annot"><span class="annottext">[Bag GlobalRdrElt]
</span><a href="#local-6989586621681175464"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-223"></span><span>
</span><span id="line-224"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcFImport"><span class="hs-identifier hs-type">tcFImport</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-225"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-226"></span><span id="tcFImport"><span class="annot"><span class="annottext">tcFImport :: LForeignDecl GhcRn
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcFImport"><span class="hs-identifier hs-var hs-var">tcFImport</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175462"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175462"><span class="hs-identifier hs-var">dloc</span></a></span></span><span> </span><span id="local-6989586621681175461"><span class="annot"><span class="annottext">fo :: ForeignDecl GhcRn
</span><a href="#local-6989586621681175461"><span class="hs-identifier hs-var">fo</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignImport"><span class="hs-identifier hs-type">ForeignImport</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fd_name :: forall pass. ForeignDecl pass -&gt; Located (IdP pass)
</span><a href="GHC.Hs.Decls.html#fd_name"><span class="hs-identifier hs-var">fd_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175459"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175459"><span class="hs-identifier hs-var">nloc</span></a></span></span><span> </span><span id="local-6989586621681175458"><span class="annot"><span class="annottext">IdP GhcRn
</span><a href="#local-6989586621681175458"><span class="hs-identifier hs-var">nm</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_sig_ty :: forall pass. ForeignDecl pass -&gt; LHsSigType pass
</span><a href="GHC.Hs.Decls.html#fd_sig_ty"><span class="hs-identifier hs-var">fd_sig_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681175456"><span class="annot"><span class="annottext">LHsSigType GhcRn
</span><a href="#local-6989586621681175456"><span class="hs-identifier hs-var">hs_ty</span></a></span></span><span>
</span><span id="line-227"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_fi :: forall pass. ForeignDecl pass -&gt; ForeignImport
</span><a href="GHC.Hs.Decls.html#fd_fi"><span class="hs-identifier hs-var">fd_fi</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681175454"><span class="annot"><span class="annottext">ForeignImport
</span><a href="#local-6989586621681175454"><span class="hs-identifier hs-var">imp_decl</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-228"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175462"><span class="hs-identifier hs-var">dloc</span></a></span><span> </span><span class="annot"><span class="annottext">(IOEnv
   (Env TcGblEnv TcLclEnv)
   (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
 -&gt; IOEnv
      (Env TcGblEnv TcLclEnv)
      (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt))
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
forall a. MsgDoc -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxt"><span class="hs-identifier hs-var">addErrCtxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignDecl GhcRn -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#foreignDeclCtxt"><span class="hs-identifier hs-var">foreignDeclCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignDecl GhcRn
</span><a href="#local-6989586621681175461"><span class="hs-identifier hs-var">fo</span></a></span><span class="hs-special">)</span><span>  </span><span class="annot"><span class="annottext">(IOEnv
   (Env TcGblEnv TcLclEnv)
   (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
 -&gt; IOEnv
      (Env TcGblEnv TcLclEnv)
      (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt))
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-229"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681175450"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175450"><span class="hs-identifier hs-var">sig_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; LHsSigType GhcRn -&gt; TcM Type
</span><a href="GHC.Tc.Gen.HsType.html#tcHsSigType"><span class="hs-identifier hs-var">tcHsSigType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#ForSigCtxt"><span class="hs-identifier hs-var">ForSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
IdP GhcRn
</span><a href="#local-6989586621681175458"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LHsSigType GhcRn
</span><a href="#local-6989586621681175456"><span class="hs-identifier hs-var">hs_ty</span></a></span><span>
</span><span id="line-230"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175447"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175447"><span class="hs-identifier hs-var">norm_co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175446"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175446"><span class="hs-identifier hs-var">norm_sig_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175445"><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175445"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#normaliseFfiType"><span class="hs-identifier hs-var">normaliseFfiType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175450"><span class="hs-identifier hs-var">sig_ty</span></a></span><span>
</span><span id="line-231"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span>
</span><span id="line-232"></span><span>           </span><span class="hs-comment">-- Drop the foralls before inspecting the</span><span>
</span><span id="line-233"></span><span>           </span><span class="hs-comment">-- structure of the foreign type.</span><span>
</span><span id="line-234"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621681175444"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175444"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175443"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175443"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([Scaled Type], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTys"><span class="hs-identifier hs-var">tcSplitFunTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Core.Type.html#dropForAlls"><span class="hs-identifier hs-var">dropForAlls</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175446"><span class="hs-identifier hs-var">norm_sig_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-235"></span><span>             </span><span id="local-6989586621681175440"><span class="annot"><span class="annottext">id :: TyCoVar
</span><a href="#local-6989586621681175440"><span class="hs-identifier hs-var hs-var">id</span></a></span></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; Type -&gt; Type -&gt; TyCoVar
Name -&gt; Type -&gt; Type -&gt; TyCoVar
</span><a href="GHC.Types.Id.html#mkLocalId"><span class="hs-identifier hs-var">mkLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
IdP GhcRn
</span><a href="#local-6989586621681175458"><span class="hs-identifier hs-var">nm</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175450"><span class="hs-identifier hs-var">sig_ty</span></a></span><span>
</span><span id="line-236"></span><span>                 </span><span class="hs-comment">-- Use a LocalId to obey the invariant that locally-defined</span><span>
</span><span id="line-237"></span><span>                 </span><span class="hs-comment">-- things are LocalIds.  However, it does not need zonking,</span><span>
</span><span id="line-238"></span><span>                 </span><span class="hs-comment">-- (so GHC.Tc.Utils.Zonk.zonkForeignExports ignores it).</span><span>
</span><span id="line-239"></span><span>
</span><span id="line-240"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681175437"><span class="annot"><span class="annottext">ForeignImport
</span><a href="#local-6989586621681175437"><span class="hs-identifier hs-var">imp_decl'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Scaled Type] -&gt; Type -&gt; ForeignImport -&gt; TcM ForeignImport
</span><a href="GHC.Tc.Gen.Foreign.html#tcCheckFIType"><span class="hs-identifier hs-var">tcCheckFIType</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175444"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175443"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignImport
</span><a href="#local-6989586621681175454"><span class="hs-identifier hs-var">imp_decl</span></a></span><span>
</span><span id="line-241"></span><span>          </span><span class="hs-comment">-- Can't use sig_ty here because sig_ty :: Type and</span><span>
</span><span id="line-242"></span><span>          </span><span class="hs-comment">-- we need HsType Id hence the undefined</span><span>
</span><span id="line-243"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681175436"><span class="annot"><span class="annottext">fi_decl :: ForeignDecl GhcTc
</span><a href="#local-6989586621681175436"><span class="hs-identifier hs-var hs-var">fi_decl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignImport :: forall pass.
XForeignImport pass
-&gt; Located (IdP pass)
-&gt; LHsSigType pass
-&gt; ForeignImport
-&gt; ForeignDecl pass
</span><a href="GHC.Hs.Decls.html#ForeignImport"><span class="hs-identifier hs-type">ForeignImport</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fd_name :: Located (IdP GhcTc)
</span><a href="GHC.Hs.Decls.html#fd_name"><span class="hs-identifier hs-var">fd_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TyCoVar -&gt; GenLocated SrcSpan TyCoVar
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175459"><span class="hs-identifier hs-var">nloc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621681175440"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-244"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_sig_ty :: LHsSigType GhcTc
</span><a href="GHC.Hs.Decls.html#fd_sig_ty"><span class="hs-identifier hs-var">fd_sig_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsSigType GhcTc
forall a. HasCallStack =&gt; a
</span><a href="../../base/src/GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-245"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_i_ext :: XForeignImport GhcTc
</span><a href="GHC.Hs.Decls.html#fd_i_ext"><span class="hs-identifier hs-var">fd_i_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Coercion
</span><a href="GHC.Core.Coercion.html#mkSymCo"><span class="hs-identifier hs-var">mkSymCo</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175447"><span class="hs-identifier hs-var">norm_co</span></a></span><span>
</span><span id="line-246"></span><span>                                     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_fi :: ForeignImport
</span><a href="GHC.Hs.Decls.html#fd_fi"><span class="hs-identifier hs-var">fd_fi</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignImport
</span><a href="#local-6989586621681175437"><span class="hs-identifier hs-var">imp_decl'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-247"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621681175440"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; ForeignDecl GhcTc -&gt; LForeignDecl GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175462"><span class="hs-identifier hs-var">dloc</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignDecl GhcTc
</span><a href="#local-6989586621681175436"><span class="hs-identifier hs-var">fi_decl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175445"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-248"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcFImport"><span class="hs-identifier hs-var">tcFImport</span></a></span><span> </span><span id="local-6989586621681175432"><span class="annot"><span class="annottext">LForeignDecl GhcRn
</span><a href="#local-6989586621681175432"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; MsgDoc
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     (TyCoVar, LForeignDecl GhcTc, Bag GlobalRdrElt)
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcFImport&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LForeignDecl GhcRn -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">LForeignDecl GhcRn
</span><a href="#local-6989586621681175432"><span class="hs-identifier hs-var">d</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-249"></span><span>
</span><span id="line-250"></span><span class="hs-comment">-- ------------ Checking types for foreign import ----------------------</span><span>
</span><span id="line-251"></span><span>
</span><span id="line-252"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcCheckFIType"><span class="hs-identifier hs-type">tcCheckFIType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignImport"><span class="hs-identifier hs-type">ForeignImport</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignImport"><span class="hs-identifier hs-type">ForeignImport</span></a></span><span>
</span><span id="line-253"></span><span>
</span><span id="line-254"></span><span id="tcCheckFIType"><span class="annot"><span class="annottext">tcCheckFIType :: [Scaled Type] -&gt; Type -&gt; ForeignImport -&gt; TcM ForeignImport
</span><a href="GHC.Tc.Gen.Foreign.html#tcCheckFIType"><span class="hs-identifier hs-var hs-var">tcCheckFIType</span></a></span></span><span> </span><span id="local-6989586621681175429"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175429"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span> </span><span id="local-6989586621681175428"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175428"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CImport"><span class="hs-identifier hs-type">CImport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175426"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175426"><span class="hs-identifier hs-var">lc</span></a></span></span><span> </span><span id="local-6989586621681175425"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175425"><span class="hs-identifier hs-var">cconv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681175424"><span class="annot"><span class="annottext">Located Safety
</span><a href="#local-6989586621681175424"><span class="hs-identifier hs-var">safety</span></a></span></span><span> </span><span id="local-6989586621681175423"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681175423"><span class="hs-identifier hs-var">mh</span></a></span></span><span> </span><span id="local-6989586621681175422"><span class="annot"><span class="annottext">l :: CImportSpec
</span><a href="#local-6989586621681175422"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CLabel"><span class="hs-identifier hs-type">CLabel</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681175420"><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175420"><span class="hs-identifier hs-var">src</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-255"></span><span>  </span><span class="hs-comment">-- Foreign import label</span><span>
</span><span id="line-256"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">(HscTarget -&gt; Validity) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-var">checkCg</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span>
</span><span id="line-257"></span><span>       </span><span class="hs-comment">-- NB check res_ty not sig_ty!</span><span>
</span><span id="line-258"></span><span>       </span><span class="hs-comment">--    In case sig_ty is (forall a. ForeignPtr a)</span><span>
</span><span id="line-259"></span><span>       </span><span class="annot"><span class="annottext">Validity -&gt; (MsgDoc -&gt; MsgDoc) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#check"><span class="hs-identifier hs-var">check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFILabelTy"><span class="hs-identifier hs-var">isFFILabelTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Scaled Type] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTys"><span class="hs-identifier hs-var">mkVisFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175429"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175428"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">Outputable.empty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-260"></span><span>       </span><span id="local-6989586621681175412"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175412"><span class="hs-identifier hs-var">cconv'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
</span><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175425"><span class="hs-identifier hs-var">cconv</span></a></span><span>
</span><span id="line-261"></span><span>       </span><span class="annot"><span class="annottext">ForeignImport -&gt; TcM ForeignImport
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenLocated SrcSpan CCallConv
-&gt; Located Safety
-&gt; Maybe Header
-&gt; CImportSpec
-&gt; Located SourceText
-&gt; ForeignImport
</span><a href="GHC.Hs.Decls.html#CImport"><span class="hs-identifier hs-var">CImport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; CCallConv -&gt; GenLocated SrcSpan CCallConv
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175426"><span class="hs-identifier hs-var">lc</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175412"><span class="hs-identifier hs-var">cconv'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Located Safety
</span><a href="#local-6989586621681175424"><span class="hs-identifier hs-var">safety</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681175423"><span class="hs-identifier hs-var">mh</span></a></span><span> </span><span class="annot"><span class="annottext">CImportSpec
</span><a href="#local-6989586621681175422"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175420"><span class="hs-identifier hs-var">src</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-262"></span><span>
</span><span id="line-263"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcCheckFIType"><span class="hs-identifier hs-var">tcCheckFIType</span></a></span><span> </span><span id="local-6989586621681175410"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175410"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span> </span><span id="local-6989586621681175409"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175409"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CImport"><span class="hs-identifier hs-type">CImport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175408"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175408"><span class="hs-identifier hs-var">lc</span></a></span></span><span> </span><span id="local-6989586621681175407"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175407"><span class="hs-identifier hs-var">cconv</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681175406"><span class="annot"><span class="annottext">Located Safety
</span><a href="#local-6989586621681175406"><span class="hs-identifier hs-var">safety</span></a></span></span><span> </span><span id="local-6989586621681175405"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681175405"><span class="hs-identifier hs-var">mh</span></a></span></span><span> </span><span class="annot"><span class="annottext">CImportSpec
</span><a href="GHC.Hs.Decls.html#CWrapper"><span class="hs-identifier hs-var">CWrapper</span></a></span><span> </span><span id="local-6989586621681175403"><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175403"><span class="hs-identifier hs-var">src</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-264"></span><span>        </span><span class="hs-comment">-- Foreign wrapper (former f.e.d.)</span><span>
</span><span id="line-265"></span><span>        </span><span class="hs-comment">-- The type must be of the form ft -&gt; IO (FunPtr ft), where ft is a valid</span><span>
</span><span id="line-266"></span><span>        </span><span class="hs-comment">-- foreign type.  For legacy reasons ft -&gt; IO (Ptr ft) is accepted, too.</span><span>
</span><span id="line-267"></span><span>        </span><span class="hs-comment">-- The use of the latter form is DEPRECATED, though.</span><span>
</span><span id="line-268"></span><span>    </span><span class="annot"><span class="annottext">(HscTarget -&gt; Validity) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-var">checkCg</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span>
</span><span id="line-269"></span><span>    </span><span id="local-6989586621681175402"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175402"><span class="hs-identifier hs-var">cconv'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
</span><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175407"><span class="hs-identifier hs-var">cconv</span></a></span><span>
</span><span id="line-270"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175410"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-271"></span><span>        </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681175400"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175400"><span class="hs-identifier hs-var">arg1_mult</span></a></span></span><span> </span><span id="local-6989586621681175399"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175399"><span class="hs-identifier hs-var">arg1_ty</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-272"></span><span>                        </span><span class="annot"><span class="annottext">Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkNoLinearFFI"><span class="hs-identifier hs-var">checkNoLinearFFI</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175400"><span class="hs-identifier hs-var">arg1_mult</span></a></span><span>
</span><span id="line-273"></span><span>                        </span><span class="annot"><span class="annottext">(Type -&gt; Validity) -&gt; [Scaled Type] -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignArgs"><span class="hs-identifier hs-var">checkForeignArgs</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIExternalTy"><span class="hs-identifier hs-var">isFFIExternalTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175396"><span class="hs-identifier hs-var">arg1_tys</span></a></span><span>
</span><span id="line-274"></span><span>                        </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; (Type -&gt; Validity) -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier hs-var">checkForeignRes</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#nonIOok"><span class="hs-identifier hs-var">nonIOok</span></a></span><span>  </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#checkSafe"><span class="hs-identifier hs-var">checkSafe</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIExportResultTy"><span class="hs-identifier hs-var">isFFIExportResultTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175394"><span class="hs-identifier hs-var">res1_ty</span></a></span><span>
</span><span id="line-275"></span><span>                        </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; (Type -&gt; Validity) -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier hs-var">checkForeignRes</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#mustBeIO"><span class="hs-identifier hs-var">mustBeIO</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#checkSafe"><span class="hs-identifier hs-var">checkSafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIDynTy"><span class="hs-identifier hs-var">isFFIDynTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175399"><span class="hs-identifier hs-var">arg1_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175409"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-276"></span><span>                  </span><span class="hs-keyword">where</span><span>
</span><span id="line-277"></span><span>                     </span><span class="hs-special">(</span><span id="local-6989586621681175396"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175396"><span class="hs-identifier hs-var">arg1_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175394"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175394"><span class="hs-identifier hs-var">res1_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([Scaled Type], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTys"><span class="hs-identifier hs-var">tcSplitFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175399"><span class="hs-identifier hs-var">arg1_ty</span></a></span><span>
</span><span id="line-278"></span><span>        </span><span class="annot"><span class="annottext">[Scaled Type]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">Outputable.empty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;One argument expected&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span>    </span><span class="annot"><span class="annottext">ForeignImport -&gt; TcM ForeignImport
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenLocated SrcSpan CCallConv
-&gt; Located Safety
-&gt; Maybe Header
-&gt; CImportSpec
-&gt; Located SourceText
-&gt; ForeignImport
</span><a href="GHC.Hs.Decls.html#CImport"><span class="hs-identifier hs-var">CImport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; CCallConv -&gt; GenLocated SrcSpan CCallConv
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175408"><span class="hs-identifier hs-var">lc</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175402"><span class="hs-identifier hs-var">cconv'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Located Safety
</span><a href="#local-6989586621681175406"><span class="hs-identifier hs-var">safety</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681175405"><span class="hs-identifier hs-var">mh</span></a></span><span> </span><span class="annot"><span class="annottext">CImportSpec
</span><a href="GHC.Hs.Decls.html#CWrapper"><span class="hs-identifier hs-var">CWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175403"><span class="hs-identifier hs-var">src</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-280"></span><span>
</span><span id="line-281"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcCheckFIType"><span class="hs-identifier hs-var">tcCheckFIType</span></a></span><span> </span><span id="local-6989586621681175390"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175390"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span> </span><span id="local-6989586621681175389"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175389"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span id="local-6989586621681175388"><span class="annot"><span class="annottext">idecl :: ForeignImport
</span><a href="#local-6989586621681175388"><span class="hs-identifier hs-var">idecl</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CImport"><span class="hs-identifier hs-type">CImport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175387"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175387"><span class="hs-identifier hs-var">lc</span></a></span></span><span> </span><span id="local-6989586621681175386"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175386"><span class="hs-identifier hs-var">cconv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175385"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175385"><span class="hs-identifier hs-var">ls</span></a></span></span><span> </span><span id="local-6989586621681175384"><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681175384"><span class="hs-identifier hs-var">safety</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681175383"><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681175383"><span class="hs-identifier hs-var">mh</span></a></span></span><span>
</span><span id="line-282"></span><span>                                            </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CFunction"><span class="hs-identifier hs-type">CFunction</span></a></span><span> </span><span id="local-6989586621681175381"><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681175381"><span class="hs-identifier hs-var">target</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681175380"><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175380"><span class="hs-identifier hs-var">src</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-283"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CCallTarget -&gt; Bool
</span><a href="GHC.Types.ForeignCall.html#isDynamicTarget"><span class="hs-identifier hs-var">isDynamicTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681175381"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-comment">-- Foreign import dynamic</span><span>
</span><span id="line-284"></span><span>      </span><span class="annot"><span class="annottext">(HscTarget -&gt; Validity) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-var">checkCg</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span>
</span><span id="line-285"></span><span>      </span><span id="local-6989586621681175378"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175378"><span class="hs-identifier hs-var">cconv'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
</span><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175386"><span class="hs-identifier hs-var">cconv</span></a></span><span>
</span><span id="line-286"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175390"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="hs-keyword">of</span><span>           </span><span class="hs-comment">-- The first arg must be Ptr or FunPtr</span><span>
</span><span id="line-287"></span><span>        </span><span class="hs-special">[</span><span class="hs-special">]</span><span>                </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-288"></span><span>          </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Utils.Outputable.html#empty"><span class="hs-identifier hs-var">Outputable.empty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;At least one argument expected&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-289"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681175377"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175377"><span class="hs-identifier hs-var">arg1_mult</span></a></span></span><span> </span><span id="local-6989586621681175376"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175376"><span class="hs-identifier hs-var">arg1_ty</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681175375"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175375"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-290"></span><span>          </span><span id="local-6989586621681175374"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175374"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-291"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681175372"><span class="annot"><span class="annottext">curried_res_ty :: Type
</span><a href="#local-6989586621681175372"><span class="hs-identifier hs-var hs-var">curried_res_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Scaled Type] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkVisFunTys"><span class="hs-identifier hs-var">mkVisFunTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175375"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175389"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-292"></span><span>          </span><span class="annot"><span class="annottext">Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkNoLinearFFI"><span class="hs-identifier hs-var">checkNoLinearFFI</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175377"><span class="hs-identifier hs-var">arg1_mult</span></a></span><span>
</span><span id="line-293"></span><span>          </span><span class="annot"><span class="annottext">Validity -&gt; (MsgDoc -&gt; MsgDoc) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#check"><span class="hs-identifier hs-var">check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIDynTy"><span class="hs-identifier hs-var">isFFIDynTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175372"><span class="hs-identifier hs-var">curried_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175376"><span class="hs-identifier hs-var">arg1_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#argument"><span class="hs-identifier hs-var">argument</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-295"></span><span>          </span><span class="annot"><span class="annottext">(Type -&gt; Validity) -&gt; [Scaled Type] -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignArgs"><span class="hs-identifier hs-var">checkForeignArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Safety -&gt; Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIArgumentTy"><span class="hs-identifier hs-var">isFFIArgumentTy</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175374"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681175384"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175375"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-296"></span><span>          </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; (Type -&gt; Validity) -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier hs-var">checkForeignRes</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#nonIOok"><span class="hs-identifier hs-var">nonIOok</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#checkSafe"><span class="hs-identifier hs-var">checkSafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIImportResultTy"><span class="hs-identifier hs-var">isFFIImportResultTy</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175374"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175389"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-297"></span><span>      </span><span class="annot"><span class="annottext">ForeignImport -&gt; TcM ForeignImport
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ForeignImport -&gt; TcM ForeignImport)
-&gt; ForeignImport -&gt; TcM ForeignImport
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan CCallConv
-&gt; Located Safety
-&gt; Maybe Header
-&gt; CImportSpec
-&gt; Located SourceText
-&gt; ForeignImport
</span><a href="GHC.Hs.Decls.html#CImport"><span class="hs-identifier hs-var">CImport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; CCallConv -&gt; GenLocated SrcSpan CCallConv
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175387"><span class="hs-identifier hs-var">lc</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175378"><span class="hs-identifier hs-var">cconv'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; Safety -&gt; Located Safety
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175385"><span class="hs-identifier hs-var">ls</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681175384"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681175383"><span class="hs-identifier hs-var">mh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallTarget -&gt; CImportSpec
</span><a href="GHC.Hs.Decls.html#CFunction"><span class="hs-identifier hs-var">CFunction</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681175381"><span class="hs-identifier hs-var">target</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175380"><span class="hs-identifier hs-var">src</span></a></span><span>
</span><span id="line-298"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175386"><span class="hs-identifier hs-var">cconv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; CCallConv -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#PrimCallConv"><span class="hs-identifier hs-var">PrimCallConv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-299"></span><span>      </span><span id="local-6989586621681175367"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175367"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-300"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#xopt"><span class="hs-identifier hs-var">xopt</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#GHCForeignImportPrim"><span class="hs-identifier hs-var">LangExt.GHCForeignImportPrim</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175367"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-301"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Use GHCForeignImportPrim to allow `foreign import prim'.&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-302"></span><span>      </span><span class="annot"><span class="annottext">(HscTarget -&gt; Validity) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-var">checkCg</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span>
</span><span id="line-303"></span><span>      </span><span class="annot"><span class="annottext">CCallTarget -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCTarget"><span class="hs-identifier hs-var">checkCTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681175381"><span class="hs-identifier hs-var">target</span></a></span><span>
</span><span id="line-304"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Safety -&gt; Bool
</span><a href="GHC.Types.ForeignCall.html#playSafe"><span class="hs-identifier hs-var">playSafe</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681175384"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-305"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;The safe/unsafe annotation should not be used with `foreign import prim'.&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-306"></span><span>      </span><span class="annot"><span class="annottext">(Type -&gt; Validity) -&gt; [Scaled Type] -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignArgs"><span class="hs-identifier hs-var">checkForeignArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIPrimArgumentTy"><span class="hs-identifier hs-var">isFFIPrimArgumentTy</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175367"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175390"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-307"></span><span>      </span><span class="hs-comment">-- prim import result is more liberal, allows (#,,#)</span><span>
</span><span id="line-308"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; (Type -&gt; Validity) -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier hs-var">checkForeignRes</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#nonIOok"><span class="hs-identifier hs-var">nonIOok</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#checkSafe"><span class="hs-identifier hs-var">checkSafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIPrimResultTy"><span class="hs-identifier hs-var">isFFIPrimResultTy</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175367"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175389"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-309"></span><span>      </span><span class="annot"><span class="annottext">ForeignImport -&gt; TcM ForeignImport
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignImport
</span><a href="#local-6989586621681175388"><span class="hs-identifier hs-var">idecl</span></a></span><span>
</span><span id="line-310"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>              </span><span class="hs-comment">-- Normal foreign import</span><span>
</span><span id="line-311"></span><span>      </span><span class="annot"><span class="annottext">(HscTarget -&gt; Validity) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-var">checkCg</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span>
</span><span id="line-312"></span><span>      </span><span id="local-6989586621681175360"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175360"><span class="hs-identifier hs-var">cconv'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
</span><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175386"><span class="hs-identifier hs-var">cconv</span></a></span><span>
</span><span id="line-313"></span><span>      </span><span class="annot"><span class="annottext">CCallTarget -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCTarget"><span class="hs-identifier hs-var">checkCTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681175381"><span class="hs-identifier hs-var">target</span></a></span><span>
</span><span id="line-314"></span><span>      </span><span id="local-6989586621681175359"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175359"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-315"></span><span>      </span><span class="annot"><span class="annottext">(Type -&gt; Validity) -&gt; [Scaled Type] -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignArgs"><span class="hs-identifier hs-var">checkForeignArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Safety -&gt; Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIArgumentTy"><span class="hs-identifier hs-var">isFFIArgumentTy</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175359"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681175384"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175390"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-316"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; (Type -&gt; Validity) -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier hs-var">checkForeignRes</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#nonIOok"><span class="hs-identifier hs-var">nonIOok</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#checkSafe"><span class="hs-identifier hs-var">checkSafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIImportResultTy"><span class="hs-identifier hs-var">isFFIImportResultTy</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175359"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175389"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-317"></span><span>      </span><span class="annot"><span class="annottext">DynFlags -&gt; [Type] -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkMissingAmpersand"><span class="hs-identifier hs-var">checkMissingAmpersand</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175359"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Scaled Type -&gt; Type) -&gt; [Scaled Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175390"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175389"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-318"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681175381"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-319"></span><span>          </span><span class="annot"><a href="GHC.Types.ForeignCall.html#StaticTarget"><span class="hs-identifier hs-type">StaticTarget</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Maybe Unit
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-320"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Scaled Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175390"><span class="hs-identifier hs-var">arg_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-321"></span><span>              </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;`value' imports cannot have function types&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-322"></span><span>          </span><span class="annot"><span class="annottext">CCallTarget
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-323"></span><span>      </span><span class="annot"><span class="annottext">ForeignImport -&gt; TcM ForeignImport
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ForeignImport -&gt; TcM ForeignImport)
-&gt; ForeignImport -&gt; TcM ForeignImport
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan CCallConv
-&gt; Located Safety
-&gt; Maybe Header
-&gt; CImportSpec
-&gt; Located SourceText
-&gt; ForeignImport
</span><a href="GHC.Hs.Decls.html#CImport"><span class="hs-identifier hs-var">CImport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; CCallConv -&gt; GenLocated SrcSpan CCallConv
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175387"><span class="hs-identifier hs-var">lc</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175360"><span class="hs-identifier hs-var">cconv'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; Safety -&gt; Located Safety
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175385"><span class="hs-identifier hs-var">ls</span></a></span><span> </span><span class="annot"><span class="annottext">Safety
</span><a href="#local-6989586621681175384"><span class="hs-identifier hs-var">safety</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Header
</span><a href="#local-6989586621681175383"><span class="hs-identifier hs-var">mh</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CCallTarget -&gt; CImportSpec
</span><a href="GHC.Hs.Decls.html#CFunction"><span class="hs-identifier hs-var">CFunction</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="#local-6989586621681175381"><span class="hs-identifier hs-var">target</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175380"><span class="hs-identifier hs-var">src</span></a></span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span>
</span><span id="line-326"></span><span class="hs-comment">-- This makes a convenient place to check</span><span>
</span><span id="line-327"></span><span class="hs-comment">-- that the C identifier is valid for C</span><span>
</span><span id="line-328"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCTarget"><span class="hs-identifier hs-type">checkCTarget</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallTarget"><span class="hs-identifier hs-type">CCallTarget</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span id="checkCTarget"><span class="annot"><span class="annottext">checkCTarget :: CCallTarget -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCTarget"><span class="hs-identifier hs-var hs-var">checkCTarget</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#StaticTarget"><span class="hs-identifier hs-type">StaticTarget</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681175355"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175355"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Unit
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-330"></span><span>    </span><span class="annot"><span class="annottext">(HscTarget -&gt; Validity) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-var">checkCg</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span>
</span><span id="line-331"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; Bool
</span><a href="GHC.Types.ForeignCall.html#isCLabelString"><span class="hs-identifier hs-var">isCLabelString</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175355"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#badCName"><span class="hs-identifier hs-var">badCName</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175355"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-332"></span><span>
</span><span id="line-333"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCTarget"><span class="hs-identifier hs-var">checkCTarget</span></a></span><span> </span><span class="annot"><span class="annottext">CCallTarget
</span><a href="GHC.Types.ForeignCall.html#DynamicTarget"><span class="hs-identifier hs-var">DynamicTarget</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcM ()
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkCTarget DynamicTarget&quot;</span></span><span>
</span><span id="line-334"></span><span>
</span><span id="line-335"></span><span>
</span><span id="line-336"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkMissingAmpersand"><span class="hs-identifier hs-type">checkMissingAmpersand</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-337"></span><span id="checkMissingAmpersand"><span class="annot"><span class="annottext">checkMissingAmpersand :: DynFlags -&gt; [Type] -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkMissingAmpersand"><span class="hs-identifier hs-var hs-var">checkMissingAmpersand</span></a></span></span><span> </span><span id="local-6989586621681175350"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175350"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681175349"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175349"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span> </span><span id="local-6989586621681175348"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175348"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-338"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681175349"><span class="hs-identifier hs-var">arg_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#isFunPtrTy"><span class="hs-identifier hs-var">isFunPtrTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175348"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-339"></span><span>    </span><span class="annot"><span class="annottext">WarningFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#wopt"><span class="hs-identifier hs-var">wopt</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnDodgyForeignImports"><span class="hs-identifier hs-var">Opt_WarnDodgyForeignImports</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175350"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-340"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WarnReason -&gt; MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addWarn"><span class="hs-identifier hs-var">addWarn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WarningFlag -&gt; WarnReason
</span><a href="GHC.Driver.Flags.html#Reason"><span class="hs-identifier hs-var">Reason</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnDodgyForeignImports"><span class="hs-identifier hs-var">Opt_WarnDodgyForeignImports</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-341"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;possible missing &amp; in foreign import of FunPtr&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-342"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-343"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-344"></span><span>
</span><span id="line-345"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Exports}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-352"></span><span>
</span><span id="line-353"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcForeignExports"><span class="hs-identifier hs-type">tcForeignExports</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-354"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-355"></span><span id="tcForeignExports"><span class="annot"><span class="annottext">tcForeignExports :: [LForeignDecl GhcRn]
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcForeignExports"><span class="hs-identifier hs-var hs-var">tcForeignExports</span></a></span></span><span> </span><span id="local-6989586621681175341"><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
</span><a href="#local-6989586621681175341"><span class="hs-identifier hs-var">decls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-356"></span><span>  </span><span class="annot"><span class="annottext">(Hooks
 -&gt; Maybe
      ([LForeignDecl GhcRn]
       -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)))
-&gt; ([LForeignDecl GhcRn]
    -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv)
     ([LForeignDecl GhcRn]
      -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
forall (f :: * -&gt; *) a.
(Functor f, HasDynFlags f) =&gt;
(Hooks -&gt; Maybe a) -&gt; a -&gt; f a
</span><a href="GHC.Driver.Hooks.html#getHooked"><span class="hs-identifier hs-var">getHooked</span></a></span><span> </span><span class="annot"><span class="annottext">Hooks
-&gt; Maybe
     ([LForeignDecl GhcRn]
      -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
</span><a href="GHC.Driver.Hooks.html#tcForeignExportsHook"><span class="hs-identifier hs-var hs-var">tcForeignExportsHook</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcForeignExports%27"><span class="hs-identifier hs-var">tcForeignExports'</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv
  (Env TcGblEnv TcLclEnv)
  ([LForeignDecl GhcRn]
   -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; (([LForeignDecl GhcRn]
     -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
    -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([LForeignDecl GhcRn]
 -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; [LForeignDecl GhcRn]
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
</span><a href="#local-6989586621681175341"><span class="hs-identifier hs-var">decls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-357"></span><span>
</span><span id="line-358"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcForeignExports%27"><span class="hs-identifier hs-type">tcForeignExports'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-359"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LForeignDecl"><span class="hs-identifier hs-type">LForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-360"></span><span class="hs-comment">-- For the (Bag GlobalRdrElt) result,</span><span>
</span><span id="line-361"></span><span class="hs-comment">-- see Note [Newtype constructor usage in foreign declarations]</span><span>
</span><span id="line-362"></span><span id="tcForeignExports%27"><span class="annot"><span class="annottext">tcForeignExports' :: [LForeignDecl GhcRn]
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcForeignExports%27"><span class="hs-identifier hs-var hs-var">tcForeignExports'</span></a></span></span><span> </span><span id="local-6989586621681175339"><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
</span><a href="#local-6989586621681175339"><span class="hs-identifier hs-var">decls</span></a></span></span><span>
</span><span id="line-363"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
 -&gt; LForeignDecl GhcRn
 -&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
-&gt; (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
-&gt; [LForeignDecl GhcRn]
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">(LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
-&gt; LForeignDecl GhcRn
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
</span><a href="#local-6989586621681175337"><span class="hs-identifier hs-var">combine</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsBinds GhcTc
forall idL idR. LHsBindsLR idL idR
</span><a href="GHC.Hs.Binds.html#emptyLHsBinds"><span class="hs-identifier hs-var">emptyLHsBinds</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LForeignDecl GhcRn -&gt; Bool)
-&gt; [LForeignDecl GhcRn] -&gt; [LForeignDecl GhcRn]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">LForeignDecl GhcRn -&gt; Bool
forall name. LForeignDecl name -&gt; Bool
</span><a href="GHC.Tc.Gen.Foreign.html#isForeignExport"><span class="hs-identifier hs-var">isForeignExport</span></a></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcRn]
</span><a href="#local-6989586621681175339"><span class="hs-identifier hs-var">decls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-364"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-365"></span><span>   </span><span id="local-6989586621681175337"><span class="annot"><span class="annottext">combine :: (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
-&gt; LForeignDecl GhcRn
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
</span><a href="#local-6989586621681175337"><span class="hs-identifier hs-var hs-var">combine</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681175333"><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681175333"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175332"><span class="annot"><span class="annottext">[LForeignDecl GhcTc]
</span><a href="#local-6989586621681175332"><span class="hs-identifier hs-var">fs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175331"><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175331"><span class="hs-identifier hs-var">gres1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175330"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175330"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681175329"><span class="annot"><span class="annottext">ForeignDecl GhcRn
</span><a href="#local-6989586621681175329"><span class="hs-identifier hs-var">fe</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-366"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621681175328"><span class="annot"><span class="annottext">LHsBind GhcTc
</span><a href="#local-6989586621681175328"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175327"><span class="annot"><span class="annottext">ForeignDecl GhcTc
</span><a href="#local-6989586621681175327"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175326"><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175326"><span class="hs-identifier hs-var">gres2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175330"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignDecl GhcRn
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcFExport"><span class="hs-identifier hs-var">tcFExport</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignDecl GhcRn
</span><a href="#local-6989586621681175329"><span class="hs-identifier hs-var">fe</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-367"></span><span>       </span><span class="annot"><span class="annottext">(LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
-&gt; TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsBind GhcTc
</span><a href="#local-6989586621681175328"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBind GhcTc -&gt; LHsBinds GhcTc -&gt; LHsBinds GhcTc
forall a. a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#consBag"><span class="hs-operator hs-var">`consBag`</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681175333"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; ForeignDecl GhcTc -&gt; LForeignDecl GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175330"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignDecl GhcTc
</span><a href="#local-6989586621681175327"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">LForeignDecl GhcTc -&gt; [LForeignDecl GhcTc] -&gt; [LForeignDecl GhcTc]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LForeignDecl GhcTc]
</span><a href="#local-6989586621681175332"><span class="hs-identifier hs-var">fs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175331"><span class="hs-identifier hs-var">gres1</span></a></span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt -&gt; Bag GlobalRdrElt -&gt; Bag GlobalRdrElt
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175326"><span class="hs-identifier hs-var">gres2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-368"></span><span>
</span><span id="line-369"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcFExport"><span class="hs-identifier hs-type">tcFExport</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignDecl"><span class="hs-identifier hs-type">ForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-370"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignDecl"><span class="hs-identifier hs-type">ForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Reader.html#GlobalRdrElt"><span class="hs-identifier hs-type">GlobalRdrElt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-371"></span><span id="tcFExport"><span class="annot"><span class="annottext">tcFExport :: ForeignDecl GhcRn
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#tcFExport"><span class="hs-identifier hs-var hs-var">tcFExport</span></a></span></span><span> </span><span id="local-6989586621681175324"><span class="annot"><span class="annottext">fo :: ForeignDecl GhcRn
</span><a href="#local-6989586621681175324"><span class="hs-identifier hs-var">fo</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignExport"><span class="hs-identifier hs-type">ForeignExport</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fd_name :: forall pass. ForeignDecl pass -&gt; Located (IdP pass)
</span><a href="GHC.Hs.Decls.html#fd_name"><span class="hs-identifier hs-var">fd_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175323"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175323"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681175322"><span class="annot"><span class="annottext">IdP GhcRn
</span><a href="#local-6989586621681175322"><span class="hs-identifier hs-var">nm</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_sig_ty :: forall pass. ForeignDecl pass -&gt; LHsSigType pass
</span><a href="GHC.Hs.Decls.html#fd_sig_ty"><span class="hs-identifier hs-var">fd_sig_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681175321"><span class="annot"><span class="annottext">LHsSigType GhcRn
</span><a href="#local-6989586621681175321"><span class="hs-identifier hs-var">hs_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_fe :: forall pass. ForeignDecl pass -&gt; ForeignExport
</span><a href="GHC.Hs.Decls.html#fd_fe"><span class="hs-identifier hs-var">fd_fe</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681175319"><span class="annot"><span class="annottext">ForeignExport
</span><a href="#local-6989586621681175319"><span class="hs-identifier hs-var">spec</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-372"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
forall a. MsgDoc -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxt"><span class="hs-identifier hs-var">addErrCtxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignDecl GhcRn -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#foreignDeclCtxt"><span class="hs-identifier hs-var">foreignDeclCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignDecl GhcRn
</span><a href="#local-6989586621681175324"><span class="hs-identifier hs-var">fo</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
 -&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt))
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-373"></span><span>
</span><span id="line-374"></span><span>    </span><span id="local-6989586621681175318"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175318"><span class="hs-identifier hs-var">sig_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; LHsSigType GhcRn -&gt; TcM Type
</span><a href="GHC.Tc.Gen.HsType.html#tcHsSigType"><span class="hs-identifier hs-var">tcHsSigType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#ForSigCtxt"><span class="hs-identifier hs-var">ForSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
IdP GhcRn
</span><a href="#local-6989586621681175322"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LHsSigType GhcRn
</span><a href="#local-6989586621681175321"><span class="hs-identifier hs-var">hs_ty</span></a></span><span>
</span><span id="line-375"></span><span>    </span><span id="local-6989586621681175317"><span class="annot"><span class="annottext">LHsExpr GhcTc
</span><a href="#local-6989586621681175317"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LHsExpr GhcRn -&gt; Type -&gt; TcM (LHsExpr GhcTc)
</span><a href="GHC.Tc.Gen.Expr.html#tcCheckPolyExpr"><span class="hs-identifier hs-var">tcCheckPolyExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdP GhcRn -&gt; LHsExpr GhcRn
forall (id :: Pass). IdP (GhcPass id) -&gt; LHsExpr (GhcPass id)
</span><a href="GHC.Hs.Utils.html#nlHsVar"><span class="hs-identifier hs-var">nlHsVar</span></a></span><span> </span><span class="annot"><span class="annottext">IdP GhcRn
</span><a href="#local-6989586621681175322"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175318"><span class="hs-identifier hs-var">sig_ty</span></a></span><span>
</span><span id="line-376"></span><span>
</span><span id="line-377"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681175314"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681175314"><span class="hs-identifier hs-var">norm_co</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175313"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175313"><span class="hs-identifier hs-var">norm_sig_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175312"><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175312"><span class="hs-identifier hs-var">gres</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM (Coercion, Type, Bag GlobalRdrElt)
</span><a href="GHC.Tc.Gen.Foreign.html#normaliseFfiType"><span class="hs-identifier hs-var">normaliseFfiType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175318"><span class="hs-identifier hs-var">sig_ty</span></a></span><span>
</span><span id="line-378"></span><span>
</span><span id="line-379"></span><span>    </span><span id="local-6989586621681175311"><span class="annot"><span class="annottext">ForeignExport
</span><a href="#local-6989586621681175311"><span class="hs-identifier hs-var">spec'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ForeignExport -&gt; TcM ForeignExport
</span><a href="GHC.Tc.Gen.Foreign.html#tcCheckFEType"><span class="hs-identifier hs-var">tcCheckFEType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175313"><span class="hs-identifier hs-var">norm_sig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignExport
</span><a href="#local-6989586621681175319"><span class="hs-identifier hs-var">spec</span></a></span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span>           </span><span class="hs-comment">-- we're exporting a function, but at a type possibly more</span><span>
</span><span id="line-382"></span><span>           </span><span class="hs-comment">-- constrained than its declared/inferred type. Hence the need</span><span>
</span><span id="line-383"></span><span>           </span><span class="hs-comment">-- to create a local binding which will call the exported function</span><span>
</span><span id="line-384"></span><span>           </span><span class="hs-comment">-- at a particular type (and, maybe, overloading).</span><span>
</span><span id="line-385"></span><span>
</span><span id="line-386"></span><span>
</span><span id="line-387"></span><span>    </span><span class="hs-comment">-- We need to give a name to the new top-level binding that</span><span>
</span><span id="line-388"></span><span>    </span><span class="hs-comment">-- is *stable* (i.e. the compiler won't change it later),</span><span>
</span><span id="line-389"></span><span>    </span><span class="hs-comment">-- because this name will be referred to by the C code stub.</span><span>
</span><span id="line-390"></span><span>    </span><span id="local-6989586621681175310"><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621681175310"><span class="hs-identifier hs-var">id</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; SrcSpan -&gt; (OccName -&gt; OccName) -&gt; TcM TyCoVar
</span><a href="GHC.Tc.Utils.Env.html#mkStableIdFromName"><span class="hs-identifier hs-var">mkStableIdFromName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
IdP GhcRn
</span><a href="#local-6989586621681175322"><span class="hs-identifier hs-var">nm</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175318"><span class="hs-identifier hs-var">sig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175323"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkForeignExportOcc"><span class="hs-identifier hs-var">mkForeignExportOcc</span></a></span><span>
</span><span id="line-391"></span><span>    </span><span class="annot"><span class="annottext">(LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">IdP GhcTc -&gt; LHsExpr GhcTc -&gt; LHsBind GhcTc
forall (p :: Pass).
IdP (GhcPass p) -&gt; LHsExpr (GhcPass p) -&gt; LHsBind (GhcPass p)
</span><a href="GHC.Hs.Utils.html#mkVarBind"><span class="hs-identifier hs-var">mkVarBind</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
IdP GhcTc
</span><a href="#local-6989586621681175310"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">LHsExpr GhcTc
</span><a href="#local-6989586621681175317"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-392"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ForeignExport :: forall pass.
XForeignExport pass
-&gt; Located (IdP pass)
-&gt; LHsSigType pass
-&gt; ForeignExport
-&gt; ForeignDecl pass
</span><a href="GHC.Hs.Decls.html#ForeignExport"><span class="hs-identifier hs-type">ForeignExport</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fd_name :: Located (IdP GhcTc)
</span><a href="GHC.Hs.Decls.html#fd_name"><span class="hs-identifier hs-var">fd_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TyCoVar -&gt; GenLocated SrcSpan TyCoVar
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175323"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCoVar
</span><a href="#local-6989586621681175310"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-393"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_sig_ty :: LHsSigType GhcTc
</span><a href="GHC.Hs.Decls.html#fd_sig_ty"><span class="hs-identifier hs-var">fd_sig_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsSigType GhcTc
forall a. HasCallStack =&gt; a
</span><a href="../../base/src/GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-394"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_e_ext :: XForeignExport GhcTc
</span><a href="#local-6989586621681175306"><span class="hs-identifier hs-var">fd_e_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Coercion
XForeignExport GhcTc
</span><a href="#local-6989586621681175314"><span class="hs-identifier hs-var">norm_co</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">fd_fe :: ForeignExport
</span><a href="GHC.Hs.Decls.html#fd_fe"><span class="hs-identifier hs-var">fd_fe</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignExport
</span><a href="#local-6989586621681175311"><span class="hs-identifier hs-var">spec'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-395"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag GlobalRdrElt
</span><a href="#local-6989586621681175312"><span class="hs-identifier hs-var">gres</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-396"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcFExport"><span class="hs-identifier hs-var">tcFExport</span></a></span><span> </span><span id="local-6989586621681175305"><span class="annot"><span class="annottext">ForeignDecl GhcRn
</span><a href="#local-6989586621681175305"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
-&gt; MsgDoc
-&gt; TcRn (LHsBind GhcTc, ForeignDecl GhcTc, Bag GlobalRdrElt)
forall a. HasCallStack =&gt; String -&gt; MsgDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcFExport&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignDecl GhcRn -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignDecl GhcRn
</span><a href="#local-6989586621681175305"><span class="hs-identifier hs-var">d</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-397"></span><span>
</span><span id="line-398"></span><span class="hs-comment">-- ------------ Checking argument types for foreign export ----------------------</span><span>
</span><span id="line-399"></span><span>
</span><span id="line-400"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#tcCheckFEType"><span class="hs-identifier hs-type">tcCheckFEType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignExport"><span class="hs-identifier hs-type">ForeignExport</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignExport"><span class="hs-identifier hs-type">ForeignExport</span></a></span><span>
</span><span id="line-401"></span><span id="tcCheckFEType"><span class="annot"><span class="annottext">tcCheckFEType :: Type -&gt; ForeignExport -&gt; TcM ForeignExport
</span><a href="GHC.Tc.Gen.Foreign.html#tcCheckFEType"><span class="hs-identifier hs-var hs-var">tcCheckFEType</span></a></span></span><span> </span><span id="local-6989586621681175304"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175304"><span class="hs-identifier hs-var">sig_ty</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#CExport"><span class="hs-identifier hs-type">CExport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681175302"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175302"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.ForeignCall.html#CExportStatic"><span class="hs-identifier hs-type">CExportStatic</span></a></span><span> </span><span id="local-6989586621681175300"><span class="annot"><span class="annottext">SourceText
</span><a href="#local-6989586621681175300"><span class="hs-identifier hs-var">esrc</span></a></span></span><span> </span><span id="local-6989586621681175299"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175299"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span id="local-6989586621681175298"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175298"><span class="hs-identifier hs-var">cconv</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681175297"><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175297"><span class="hs-identifier hs-var">src</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-402"></span><span>    </span><span class="annot"><span class="annottext">(HscTarget -&gt; Validity) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-var">checkCg</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvm"><span class="hs-identifier hs-var">checkCOrAsmOrLlvm</span></a></span><span>
</span><span id="line-403"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; Bool
</span><a href="GHC.Types.ForeignCall.html#isCLabelString"><span class="hs-identifier hs-var">isCLabelString</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175299"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#badCName"><span class="hs-identifier hs-var">badCName</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175299"><span class="hs-identifier hs-var">str</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-404"></span><span>    </span><span id="local-6989586621681175295"><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175295"><span class="hs-identifier hs-var">cconv'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
</span><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175298"><span class="hs-identifier hs-var">cconv</span></a></span><span>
</span><span id="line-405"></span><span>    </span><span class="annot"><span class="annottext">(Type -&gt; Validity) -&gt; [Scaled Type] -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignArgs"><span class="hs-identifier hs-var">checkForeignArgs</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIExternalTy"><span class="hs-identifier hs-var">isFFIExternalTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175294"><span class="hs-identifier hs-var">arg_tys</span></a></span><span>
</span><span id="line-406"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; (Type -&gt; Validity) -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier hs-var">checkForeignRes</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#nonIOok"><span class="hs-identifier hs-var">nonIOok</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="GHC.Tc.Gen.Foreign.html#noCheckSafe"><span class="hs-identifier hs-var">noCheckSafe</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="GHC.Tc.Utils.TcType.html#isFFIExportResultTy"><span class="hs-identifier hs-var">isFFIExportResultTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175293"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-407"></span><span>    </span><span class="annot"><span class="annottext">ForeignExport -&gt; TcM ForeignExport
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenLocated SrcSpan CExportSpec
-&gt; Located SourceText -&gt; ForeignExport
</span><a href="GHC.Hs.Decls.html#CExport"><span class="hs-identifier hs-var">CExport</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; CExportSpec -&gt; GenLocated SrcSpan CExportSpec
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681175302"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SourceText -&gt; CLabelString -&gt; CCallConv -&gt; CExportSpec
</span><a href="GHC.Types.ForeignCall.html#CExportStatic"><span class="hs-identifier hs-var">CExportStatic</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><a href="#local-6989586621681175300"><span class="hs-identifier hs-var">esrc</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175299"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="#local-6989586621681175295"><span class="hs-identifier hs-var">cconv'</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Located SourceText
</span><a href="#local-6989586621681175297"><span class="hs-identifier hs-var">src</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-408"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-409"></span><span>      </span><span class="hs-comment">-- Drop the foralls before inspecting</span><span>
</span><span id="line-410"></span><span>      </span><span class="hs-comment">-- the structure of the foreign type.</span><span>
</span><span id="line-411"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681175294"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175294"><span class="hs-identifier hs-var">arg_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175293"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175293"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([Scaled Type], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitFunTys"><span class="hs-identifier hs-var">tcSplitFunTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Core.Type.html#dropForAlls"><span class="hs-identifier hs-var">dropForAlls</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175304"><span class="hs-identifier hs-var">sig_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-412"></span><span>
</span><span id="line-413"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Miscellaneous}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="hs-comment">------------ Checking argument types for foreign import ----------------------</span><span>
</span><span id="line-422"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkForeignArgs"><span class="hs-identifier hs-type">checkForeignArgs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-423"></span><span id="checkForeignArgs"><span class="annot"><span class="annottext">checkForeignArgs :: (Type -&gt; Validity) -&gt; [Scaled Type] -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignArgs"><span class="hs-identifier hs-var hs-var">checkForeignArgs</span></a></span></span><span> </span><span id="local-6989586621681175292"><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="#local-6989586621681175292"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span id="local-6989586621681175291"><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175291"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Scaled Type -&gt; TcM ()) -&gt; [Scaled Type] -&gt; TcM ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type -&gt; TcM ()
</span><a href="#local-6989586621681175289"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><a href="#local-6989586621681175291"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-424"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-425"></span><span>    </span><span id="local-6989586621681175289"><span class="annot"><span class="annottext">go :: Scaled Type -&gt; TcM ()
</span><a href="#local-6989586621681175289"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span id="local-6989586621681175288"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175288"><span class="hs-identifier hs-var">mult</span></a></span></span><span> </span><span id="local-6989586621681175287"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175287"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkNoLinearFFI"><span class="hs-identifier hs-var">checkNoLinearFFI</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175288"><span class="hs-identifier hs-var">mult</span></a></span><span> </span><span class="annot"><span class="annottext">TcM () -&gt; TcM () -&gt; TcM ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span>
</span><span id="line-426"></span><span>                          </span><span class="annot"><span class="annottext">Validity -&gt; (MsgDoc -&gt; MsgDoc) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#check"><span class="hs-identifier hs-var">check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="#local-6989586621681175292"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175287"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#argument"><span class="hs-identifier hs-var">argument</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-427"></span><span>
</span><span id="line-428"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkNoLinearFFI"><span class="hs-identifier hs-type">checkNoLinearFFI</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Mult"><span class="hs-identifier hs-type">Mult</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- No linear types in FFI (#18472)</span><span>
</span><span id="line-429"></span><span id="checkNoLinearFFI"><span class="annot"><span class="annottext">checkNoLinearFFI :: Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkNoLinearFFI"><span class="hs-identifier hs-var hs-var">checkNoLinearFFI</span></a></span></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-430"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkNoLinearFFI"><span class="hs-identifier hs-var">checkNoLinearFFI</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; TcM ()) -&gt; MsgDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#argument"><span class="hs-identifier hs-var">argument</span></a></span><span>
</span><span id="line-431"></span><span>                                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Linear types are not supported in FFI declarations, see #18472&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-432"></span><span>
</span><span id="line-433"></span><span class="hs-comment">------------ Checking result types for foreign calls ----------------------</span><span>
</span><span id="line-434"></span><span class="hs-comment">-- | Check that the type has the form</span><span>
</span><span id="line-435"></span><span class="hs-comment">--    (IO t) or (t) , and that t satisfies the given predicate.</span><span>
</span><span id="line-436"></span><span class="hs-comment">-- When calling this function, any newtype wrappers (should) have been</span><span>
</span><span id="line-437"></span><span class="hs-comment">-- already dealt with by normaliseFfiType.</span><span>
</span><span id="line-438"></span><span class="hs-comment">--</span><span>
</span><span id="line-439"></span><span class="hs-comment">-- We also check that the Safe Haskell condition of FFI imports having</span><span>
</span><span id="line-440"></span><span class="hs-comment">-- results in the IO monad holds.</span><span>
</span><span id="line-441"></span><span class="hs-comment">--</span><span>
</span><span id="line-442"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier hs-type">checkForeignRes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-443"></span><span id="checkForeignRes"><span class="annot"><span class="annottext">checkForeignRes :: Bool -&gt; Bool -&gt; (Type -&gt; Validity) -&gt; Type -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkForeignRes"><span class="hs-identifier hs-var hs-var">checkForeignRes</span></a></span></span><span> </span><span id="local-6989586621681175285"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681175285"><span class="hs-identifier hs-var">non_io_result_ok</span></a></span></span><span> </span><span id="local-6989586621681175284"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681175284"><span class="hs-identifier hs-var">check_safe</span></a></span></span><span> </span><span id="local-6989586621681175283"><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="#local-6989586621681175283"><span class="hs-identifier hs-var">pred_res_ty</span></a></span></span><span> </span><span id="local-6989586621681175282"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175282"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-444"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681175281"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175281"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyCon, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitIOType_maybe"><span class="hs-identifier hs-var">tcSplitIOType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175282"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-445"></span><span>  </span><span class="hs-glyph">=</span><span>     </span><span class="hs-comment">-- Got an IO result type, that's always fine!</span><span>
</span><span id="line-446"></span><span>     </span><span class="annot"><span class="annottext">Validity -&gt; (MsgDoc -&gt; MsgDoc) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#check"><span class="hs-identifier hs-var">check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="#local-6989586621681175283"><span class="hs-identifier hs-var">pred_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175281"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#result"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-447"></span><span>
</span><span id="line-448"></span><span>  </span><span class="hs-comment">-- We disallow nested foralls in foreign types</span><span>
</span><span id="line-449"></span><span>  </span><span class="hs-comment">-- (at least, for the time being). See #16702.</span><span>
</span><span id="line-450"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcIsForAllTy"><span class="hs-identifier hs-var">tcIsForAllTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175282"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-451"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; TcM ()) -&gt; MsgDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#result"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unexpected nested forall&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-452"></span><span>
</span><span id="line-453"></span><span>  </span><span class="hs-comment">-- Case for non-IO result type with FFI Import</span><span>
</span><span id="line-454"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681175285"><span class="hs-identifier hs-var">non_io_result_ok</span></a></span><span>
</span><span id="line-455"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; TcM ()) -&gt; MsgDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#result"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;IO result type expected&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-456"></span><span>
</span><span id="line-457"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-458"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681175277"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175277"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-459"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Validity
</span><a href="#local-6989586621681175283"><span class="hs-identifier hs-var">pred_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681175282"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-460"></span><span>                </span><span class="hs-comment">-- Handle normal typecheck fail, we want to handle this first and</span><span>
</span><span id="line-461"></span><span>                </span><span class="hs-comment">-- only report safe haskell errors if the normal type check is OK.</span><span>
</span><span id="line-462"></span><span>           </span><span class="annot"><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-type">NotValid</span></a></span><span> </span><span id="local-6989586621681175275"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175275"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="annot"><span class="annottext">(MsgDoc -&gt; TcM ()) -&gt; MsgDoc -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#result"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175275"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-463"></span><span>
</span><span id="line-464"></span><span>           </span><span class="hs-comment">-- handle safe infer fail</span><span>
</span><span id="line-465"></span><span>           </span><span class="annot"><span class="annottext">Validity
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681175284"><span class="hs-identifier hs-var">check_safe</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#safeInferOn"><span class="hs-identifier hs-var">safeInferOn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175277"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-466"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">WarningMessages -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#recordUnsafeInfer"><span class="hs-identifier hs-var">recordUnsafeInfer</span></a></span><span> </span><span class="annot"><span class="annottext">WarningMessages
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span>
</span><span id="line-467"></span><span>
</span><span id="line-468"></span><span>           </span><span class="hs-comment">-- handle safe language typecheck fail</span><span>
</span><span id="line-469"></span><span>           </span><span class="annot"><span class="annottext">Validity
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681175284"><span class="hs-identifier hs-var">check_safe</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#safeLanguageOn"><span class="hs-identifier hs-var">safeLanguageOn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175277"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-470"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var">illegalForeignTyErr</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#result"><span class="hs-identifier hs-var">result</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175271"><span class="hs-identifier hs-var">safeHsErr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-471"></span><span>
</span><span id="line-472"></span><span>           </span><span class="hs-comment">-- success! non-IO return is fine</span><span>
</span><span id="line-473"></span><span>           </span><span class="annot"><span class="annottext">Validity
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-474"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-475"></span><span>    </span><span id="local-6989586621681175271"><span class="annot"><span class="annottext">safeHsErr :: MsgDoc
</span><a href="#local-6989586621681175271"><span class="hs-identifier hs-var hs-var">safeHsErr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-476"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Safe Haskell is on, all FFI imports must be in the IO monad&quot;</span></span><span>
</span><span id="line-477"></span><span>
</span><span id="line-478"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#nonIOok"><span class="hs-identifier hs-type">nonIOok</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#mustBeIO"><span class="hs-identifier hs-type">mustBeIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-479"></span><span id="nonIOok"><span class="annot"><span class="annottext">nonIOok :: Bool
</span><a href="GHC.Tc.Gen.Foreign.html#nonIOok"><span class="hs-identifier hs-var hs-var">nonIOok</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-480"></span><span id="mustBeIO"><span class="annot"><span class="annottext">mustBeIO :: Bool
</span><a href="GHC.Tc.Gen.Foreign.html#mustBeIO"><span class="hs-identifier hs-var hs-var">mustBeIO</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-481"></span><span>
</span><span id="line-482"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkSafe"><span class="hs-identifier hs-type">checkSafe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#noCheckSafe"><span class="hs-identifier hs-type">noCheckSafe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-483"></span><span id="checkSafe"><span class="annot"><span class="annottext">checkSafe :: Bool
</span><a href="GHC.Tc.Gen.Foreign.html#checkSafe"><span class="hs-identifier hs-var hs-var">checkSafe</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-484"></span><span id="noCheckSafe"><span class="annot"><span class="annottext">noCheckSafe :: Bool
</span><a href="GHC.Tc.Gen.Foreign.html#noCheckSafe"><span class="hs-identifier hs-var hs-var">noCheckSafe</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-485"></span><span>
</span><span id="line-486"></span><span class="hs-comment">-- Checking a supported backend is in use</span><span>
</span><span id="line-487"></span><span>
</span><span id="line-488"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvm"><span class="hs-identifier hs-type">checkCOrAsmOrLlvm</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#HscTarget"><span class="hs-identifier hs-type">HscTarget</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span>
</span><span id="line-489"></span><span id="checkCOrAsmOrLlvm"><span class="annot"><span class="annottext">checkCOrAsmOrLlvm :: HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvm"><span class="hs-identifier hs-var hs-var">checkCOrAsmOrLlvm</span></a></span></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscC"><span class="hs-identifier hs-var">HscC</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-490"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvm"><span class="hs-identifier hs-var">checkCOrAsmOrLlvm</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscAsm"><span class="hs-identifier hs-var">HscAsm</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-491"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvm"><span class="hs-identifier hs-var">checkCOrAsmOrLlvm</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscLlvm"><span class="hs-identifier hs-var">HscLlvm</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-492"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvm"><span class="hs-identifier hs-var">checkCOrAsmOrLlvm</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-493"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;requires unregisterised, llvm (-fllvm) or native code generation (-fasm)&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-494"></span><span>
</span><span id="line-495"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-type">checkCOrAsmOrLlvmOrInterp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#HscTarget"><span class="hs-identifier hs-type">HscTarget</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span>
</span><span id="line-496"></span><span id="checkCOrAsmOrLlvmOrInterp"><span class="annot"><span class="annottext">checkCOrAsmOrLlvmOrInterp :: HscTarget -&gt; Validity
</span><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscC"><span class="hs-identifier hs-var">HscC</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-497"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscAsm"><span class="hs-identifier hs-var">HscAsm</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-498"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscLlvm"><span class="hs-identifier hs-var">HscLlvm</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-499"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscInterpreted"><span class="hs-identifier hs-var">HscInterpreted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-500"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCOrAsmOrLlvmOrInterp"><span class="hs-identifier hs-var">checkCOrAsmOrLlvmOrInterp</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-501"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;requires interpreted, unregisterised, llvm or native code generation&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-502"></span><span>
</span><span id="line-503"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-type">checkCg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Session.html#HscTarget"><span class="hs-identifier hs-type">HscTarget</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-504"></span><span id="checkCg"><span class="annot"><span class="annottext">checkCg :: (HscTarget -&gt; Validity) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#checkCg"><span class="hs-identifier hs-var hs-var">checkCg</span></a></span></span><span> </span><span id="local-6989586621681175265"><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="#local-6989586621681175265"><span class="hs-identifier hs-var">check</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-505"></span><span>    </span><span id="local-6989586621681175264"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175264"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-506"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681175263"><span class="annot"><span class="annottext">target :: HscTarget
</span><a href="#local-6989586621681175263"><span class="hs-identifier hs-var hs-var">target</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; HscTarget
</span><a href="GHC.Driver.Session.html#hscTarget"><span class="hs-identifier hs-var hs-var">hscTarget</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175264"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-507"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="#local-6989586621681175263"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-508"></span><span>      </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscNothing"><span class="hs-identifier hs-var">HscNothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-509"></span><span>      </span><span class="annot"><span class="annottext">HscTarget
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-510"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HscTarget -&gt; Validity
</span><a href="#local-6989586621681175265"><span class="hs-identifier hs-var">check</span></a></span><span> </span><span class="annot"><span class="annottext">HscTarget
</span><a href="#local-6989586621681175263"><span class="hs-identifier hs-var">target</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-511"></span><span>          </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-512"></span><span>          </span><span class="annot"><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-type">NotValid</span></a></span><span> </span><span id="local-6989586621681175260"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175260"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal foreign declaration:&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175260"><span class="hs-identifier hs-var">err</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-513"></span><span>
</span><span id="line-514"></span><span class="hs-comment">-- Calling conventions</span><span>
</span><span id="line-515"></span><span>
</span><span id="line-516"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-type">checkCConv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-type">CCallConv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-type">CCallConv</span></a></span><span>
</span><span id="line-517"></span><span id="checkCConv"><span class="annot"><span class="annottext">checkCConv :: CCallConv -&gt; TcM CCallConv
</span><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var hs-var">checkCConv</span></a></span></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-var">CCallConv</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-var">CCallConv</span></a></span><span>
</span><span id="line-518"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CApiConv"><span class="hs-identifier hs-var">CApiConv</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CApiConv"><span class="hs-identifier hs-var">CApiConv</span></a></span><span>
</span><span id="line-519"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#StdCallConv"><span class="hs-identifier hs-var">StdCallConv</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681175255"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175255"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-520"></span><span>                             </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681175254"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681175254"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175255"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-521"></span><span>                             </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformArch"><span class="hs-identifier hs-var">platformArch</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681175254"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Arch -&gt; Arch -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#ArchX86"><span class="hs-identifier hs-var">ArchX86</span></a></span><span>
</span><span id="line-522"></span><span>                                 </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#StdCallConv"><span class="hs-identifier hs-var">StdCallConv</span></a></span><span>
</span><span id="line-523"></span><span>                                 </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-comment">-- This is a warning, not an error. see #3336</span><span>
</span><span id="line-524"></span><span>                                         </span><span class="annot"><span class="annottext">Bool -&gt; TcM () -&gt; TcM ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WarningFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#wopt"><span class="hs-identifier hs-var">wopt</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnUnsupportedCallingConventions"><span class="hs-identifier hs-var">Opt_WarnUnsupportedCallingConventions</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175255"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM () -&gt; TcM ()) -&gt; TcM () -&gt; TcM ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-525"></span><span>                                             </span><span class="annot"><span class="annottext">WarnReason -&gt; MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addWarnTc"><span class="hs-identifier hs-var">addWarnTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WarningFlag -&gt; WarnReason
</span><a href="GHC.Driver.Flags.html#Reason"><span class="hs-identifier hs-var">Reason</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnUnsupportedCallingConventions"><span class="hs-identifier hs-var">Opt_WarnUnsupportedCallingConventions</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-526"></span><span>                                                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;the 'stdcall' calling convention is unsupported on this platform,&quot;</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;treating as ccall&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-527"></span><span>                                         </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#CCallConv"><span class="hs-identifier hs-var">CCallConv</span></a></span><span>
</span><span id="line-528"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#PrimCallConv"><span class="hs-identifier hs-var">PrimCallConv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;The `prim' calling convention can only be used with `foreign import'&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-529"></span><span>                             </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#PrimCallConv"><span class="hs-identifier hs-var">PrimCallConv</span></a></span><span>
</span><span id="line-530"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#checkCConv"><span class="hs-identifier hs-var">checkCConv</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#JavaScriptCallConv"><span class="hs-identifier hs-var">JavaScriptCallConv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681175245"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175245"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-531"></span><span>                                   </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#platformArch"><span class="hs-identifier hs-var">platformArch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681175245"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Arch -&gt; Arch -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Arch
</span><a href="../../ghc-boot/src/GHC.Platform.html#ArchJavaScript"><span class="hs-identifier hs-var">ArchJavaScript</span></a></span><span>
</span><span id="line-532"></span><span>                                       </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#JavaScriptCallConv"><span class="hs-identifier hs-var">JavaScriptCallConv</span></a></span><span>
</span><span id="line-533"></span><span>                                       </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;The `javascript' calling convention is unsupported on this platform&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-534"></span><span>                                               </span><span class="annot"><span class="annottext">CCallConv -&gt; TcM CCallConv
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">CCallConv
</span><a href="GHC.Types.ForeignCall.html#JavaScriptCallConv"><span class="hs-identifier hs-var">JavaScriptCallConv</span></a></span><span>
</span><span id="line-535"></span><span>
</span><span id="line-536"></span><span class="hs-comment">-- Warnings</span><span>
</span><span id="line-537"></span><span>
</span><span id="line-538"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#check"><span class="hs-identifier hs-type">check</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-539"></span><span id="check"><span class="annot"><span class="annottext">check :: Validity -&gt; (MsgDoc -&gt; MsgDoc) -&gt; TcM ()
</span><a href="GHC.Tc.Gen.Foreign.html#check"><span class="hs-identifier hs-var hs-var">check</span></a></span></span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><span class="hs-identifier">_</span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcM ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-540"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#check"><span class="hs-identifier hs-var">check</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-type">NotValid</span></a></span><span> </span><span id="local-6989586621681175243"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175243"><span class="hs-identifier hs-var">doc</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681175242"><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="#local-6989586621681175242"><span class="hs-identifier hs-var">err_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; TcM ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="#local-6989586621681175242"><span class="hs-identifier hs-var">err_fn</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175243"><span class="hs-identifier hs-var">doc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-541"></span><span>
</span><span id="line-542"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-type">illegalForeignTyErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-543"></span><span id="illegalForeignTyErr"><span class="annot"><span class="annottext">illegalForeignTyErr :: MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#illegalForeignTyErr"><span class="hs-identifier hs-var hs-var">illegalForeignTyErr</span></a></span></span><span> </span><span id="local-6989586621681175240"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175240"><span class="hs-identifier hs-var">arg_or_res</span></a></span></span><span> </span><span id="local-6989586621681175239"><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175239"><span class="hs-identifier hs-var">extra</span></a></span></span><span>
</span><span id="line-544"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Int -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175237"><span class="hs-identifier hs-var">msg</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175239"><span class="hs-identifier hs-var">extra</span></a></span><span>
</span><span id="line-545"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-546"></span><span>    </span><span id="local-6989586621681175237"><span class="annot"><span class="annottext">msg :: MsgDoc
</span><a href="#local-6989586621681175237"><span class="hs-identifier hs-var hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hsep"><span class="hs-identifier hs-var">hsep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Unacceptable&quot;</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">MsgDoc
</span><a href="#local-6989586621681175240"><span class="hs-identifier hs-var">arg_or_res</span></a></span><span>
</span><span id="line-547"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;type in foreign declaration:&quot;</span></span><span class="hs-special">]</span><span>
</span><span id="line-548"></span><span>
</span><span id="line-549"></span><span class="hs-comment">-- Used for 'arg_or_res' argument to illegalForeignTyErr</span><span>
</span><span id="line-550"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#argument"><span class="hs-identifier hs-type">argument</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#result"><span class="hs-identifier hs-type">result</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-551"></span><span id="argument"><span class="annot"><span class="annottext">argument :: MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#argument"><span class="hs-identifier hs-var hs-var">argument</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;argument&quot;</span></span><span>
</span><span id="line-552"></span><span id="result"><span class="annot"><span class="annottext">result :: MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#result"><span class="hs-identifier hs-var hs-var">result</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;result&quot;</span></span><span>
</span><span id="line-553"></span><span>
</span><span id="line-554"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#badCName"><span class="hs-identifier hs-type">badCName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.ForeignCall.html#CLabelString"><span class="hs-identifier hs-type">CLabelString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span>
</span><span id="line-555"></span><span id="badCName"><span class="annot"><span class="annottext">badCName :: CLabelString -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#badCName"><span class="hs-identifier hs-var hs-var">badCName</span></a></span></span><span> </span><span id="local-6989586621681175235"><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175235"><span class="hs-identifier hs-var">target</span></a></span></span><span>
</span><span id="line-556"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[MsgDoc] -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CLabelString -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CLabelString
</span><a href="#local-6989586621681175235"><span class="hs-identifier hs-var">target</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is not a valid C identifier&quot;</span></span><span class="hs-special">]</span><span>
</span><span id="line-557"></span><span>
</span><span id="line-558"></span><span class="annot"><a href="GHC.Tc.Gen.Foreign.html#foreignDeclCtxt"><span class="hs-identifier hs-type">foreignDeclCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#ForeignDecl"><span class="hs-identifier hs-type">ForeignDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-559"></span><span id="foreignDeclCtxt"><span class="annot"><span class="annottext">foreignDeclCtxt :: ForeignDecl GhcRn -&gt; MsgDoc
</span><a href="GHC.Tc.Gen.Foreign.html#foreignDeclCtxt"><span class="hs-identifier hs-var hs-var">foreignDeclCtxt</span></a></span></span><span> </span><span id="local-6989586621681175232"><span class="annot"><span class="annottext">ForeignDecl GhcRn
</span><a href="#local-6989586621681175232"><span class="hs-identifier hs-var">fo</span></a></span></span><span>
</span><span id="line-560"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">MsgDoc -&gt; Int -&gt; MsgDoc -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;When checking declaration:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-561"></span><span>       </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignDecl GhcRn -&gt; MsgDoc
forall a. Outputable a =&gt; a -&gt; MsgDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignDecl GhcRn
</span><a href="#local-6989586621681175232"><span class="hs-identifier hs-var">fo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-562"></span></pre></body></html>